Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

author-stats.sql 2.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  1. --- #dep author-info
  2. --- #step Set up statistics table
  3. DROP TABLE IF EXISTS integration_stats CASCADE;
  4. CREATE TABLE integration_stats (
  5. dataset VARCHAR NOT NULL,
  6. gender VARCHAR NOT NULL,
  7. n_books INTEGER,
  8. n_actions INTEGER
  9. );
  10. --- #step Count LOC integration statistics
  11. WITH
  12. books AS (SELECT DISTINCT cluster
  13. FROM locmds.book_rec_isbn JOIN isbn_cluster USING (isbn_id))
  14. INSERT INTO integration_stats (dataset, gender, n_books)
  15. SELECT 'LOC-MDS', gender, COUNT(cluster)
  16. FROM books JOIN cluster_first_author_gender USING (cluster)
  17. GROUP BY gender;
  18. --- #step Count BookCrossing integration statistics
  19. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  20. SELECT 'BX-I', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  21. FROM bx.add_action
  22. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  23. GROUP BY COALESCE(gender, 'no-book');
  24. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  25. SELECT 'BX-E', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  26. FROM bx.rating
  27. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  28. GROUP BY COALESCE(gender, 'no-book');
  29. --- #step Count Amazon integration statistics
  30. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  31. SELECT 'AZ', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  32. FROM az.rating
  33. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  34. GROUP BY COALESCE(gender, 'no-book');
  35. --- #step Count GoodReads integration statistics
  36. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  37. SELECT 'GR-I', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  38. FROM gr.add_action
  39. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  40. GROUP BY COALESCE(gender, 'no-book');
  41. INSERT INTO integration_stats (dataset, gender, n_books, n_actions)
  42. SELECT 'GR-E', COALESCE(gender, 'no-book'), COUNT(DISTINCT book_id), COUNT(book_id)
  43. FROM gr.rating
  44. LEFT JOIN cluster_first_author_gender ON (book_id = cluster)
  45. GROUP BY COALESCE(gender, 'no-book');
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...