Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. isbn title author year shelves
  2. 0 0380795272 Krondor: The Betrayal Raymond E. Feist 1998 [fantasy, raymond-e-feist, feist, epic-fantasy...
  3. 1 1416949658 The Dark Is Rising Susan Cooper 1973 [young-adult, fantasy, ya, childrens, series, ...
  4. 2 1857231082 The Black Unicorn Terry Brooks 1987 [fantasy, sci-fi-fantasy, series, magic, lando...
  5. 3 0553803700 I, Robot Isaac Asimov 1950 [science-fiction, sci-fi, classics, scifi, sho...
  6. 4 080213825X Four Blondes Candace Bushnell 2000 [chick-lit, chicklit, chic-lit, contemporary, ...
  7. 5 0375913750 Love, Stargirl Jerry Spinelli 2007 [young-adult, ya, realistic-fiction, romance, ...
  8. 6 074349671X The Tenth Circle Jodi Picoult 2006 [jodi-picoult, contemporary, chick-lit, adult-...
  9. 7 0743454553 Vanishing Acts Jodi Picoult 2005 [jodi-picoult, chick-lit, contemporary, drama,...
  10. 8 0765317508 Aztec Gary Jennings 1980 [historical-fiction, historical, history, mexi...
  11. 9 0142501085 Marlfox Brian Jacques 1998 [fantasy, redwall, young-adult, childrens, chi...
  12.  
  13. def tanimoto_score(shelves_1, shelves_2):
  14. intersection_tanimoto = len([x for x in shelves_1 if x in shelves_2])
  15. union_tanimoto = len(shelves_1) + len(shelves_2)
  16. return(intersection_tanimoto/union_tanimoto)
  17.  
  18. similarity_df = pd.DataFrame()
  19. # for each line we compare the tags
  20. for index_1,row_1 in data.iterrows():
  21. for index_2, row_2 in data.iterrows():
  22. similarity_score = tanimoto_score(data.at[index_1,'shelves'],data.at[index_2,'shelves'])
  23. similarity_df[data.at[index_1,'title'],data.at[index_2,'title']] = similarity_score
  24.  
  25. (Krondor: The Betrayal, Krondor: The Betrayal) (Krondor: The Betrayal, The Dark Is Rising) (Krondor: The Betrayal, The Black Unicorn ) (Krondor: The Betrayal, I, Robot) (Krondor: The Betrayal, Four Blondes) (Krondor: The Betrayal, Love, Stargirl) (Krondor: The Betrayal, The Tenth Circle) (Krondor: The Betrayal, Vanishing Acts) (Krondor: The Betrayal, Aztec) (Krondor: The Betrayal, Marlfox) ... (Marlfox, Krondor: The Betrayal) (Marlfox, The Dark Is Rising) (Marlfox, The Black Unicorn ) (Marlfox, I, Robot) (Marlfox, Four Blondes) (Marlfox, Love, Stargirl) (Marlfox, The Tenth Circle) (Marlfox, Vanishing Acts) (Marlfox, Aztec) (Marlfox, Marlfox)
  26. 0 rows × 100 columns
  27.  
  28. Krondor: The Betrayal The Dark Is Rising ...
  29. Krondor: The Betrayal 1 0.75
  30. The Dark Is Rising 0.75 1
  31. ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement