{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2024-12-01T15:02:01.021005Z", "start_time": "2024-12-01T15:01:58.161848Z" }, "collapsed": true }, "outputs": [], "source": [ "import itertools\n", "import numpy as np\n", "import pandas as pd\n", "from collections import Counter\n", "from sklearn.preprocessing import LabelEncoder\n", "from sklearn.preprocessing import MultiLabelBinarizer" ] }, { "cell_type": "code", "execution_count": 2, "id": "9b91b6a97eb2b9be", "metadata": { "ExecuteTime": { "end_time": "2024-12-01T15:02:57.510795Z", "start_time": "2024-12-01T15:02:01.039033Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1259417, 7)\n" ] }, { "data": { "text/html": [ "
| \n", " | book_id | \n", "title | \n", "description | \n", "publication_year | \n", "publisher | \n", "authors | \n", "similar_books | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "1333909 | \n", "Good Harbor | \n", "Anita Diamant's international bestseller \"The ... | \n", "2001 | \n", "Simon & Schuster Audio | \n", "[626222] | \n", "[8709549, 17074050, 28937, 158816, 228563, 112... | \n", "
| 1 | \n", "7327624 | \n", "The Unschooled Wizard (Sun Wolf and Starhawk, ... | \n", "Omnibus book club edition containing the Ladie... | \n", "1987 | \n", "Nelson Doubleday, Inc. | \n", "[10333] | \n", "[19997, 828466, 1569323, 425389, 1176674, 2627... | \n", "
| 2 | \n", "6066819 | \n", "Best Friends Forever | \n", "Addie Downs and Valerie Adler were eight when ... | \n", "2009 | \n", "Atria Books | \n", "[9212] | \n", "[6604176, 6054190, 2285777, 82641, 7569453, 70... | \n", "
| 3 | \n", "287141 | \n", "The Aeneid for Boys and Girls | \n", "Relates in vigorous prose the tale of Aeneas, ... | \n", "2006 | \n", "Yesterday's Classics | \n", "[3041852] | \n", "[] | \n", "
| 4 | \n", "6066812 | \n", "All's Fairy in Love and War (Avalon: Web of Ma... | \n", "To Kara's astonishment, she discovers that a p... | \n", "2009 | \n", "Seven Seas | \n", "[19158] | \n", "[948696, 439885, 274955, 12978730, 372986, 216... | \n", "
| \n", " | book_id | \n", "title | \n", "description | \n", "publication_year | \n", "publisher | \n", "authors | \n", "similar_books | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "1333909 | \n", "Good Harbor | \n", "Anita Diamant's international bestseller \"The ... | \n", "2001 | \n", "Simon & Schuster Audio | \n", "[626222] | \n", "[8709549, 17074050, 28937, 158816, 228563, 112... | \n", "
| 1 | \n", "7327624 | \n", "The Unschooled Wizard (Sun Wolf and Starhawk, ... | \n", "Omnibus book club edition containing the Ladie... | \n", "1987 | \n", "Nelson Doubleday, Inc. | \n", "[10333] | \n", "[19997, 828466, 1569323, 425389, 1176674, 2627... | \n", "
| 2 | \n", "6066819 | \n", "Best Friends Forever | \n", "Addie Downs and Valerie Adler were eight when ... | \n", "2009 | \n", "Atria Books | \n", "[9212] | \n", "[6604176, 6054190, 2285777, 82641, 7569453, 70... | \n", "
| 4 | \n", "6066812 | \n", "All's Fairy in Love and War (Avalon: Web of Ma... | \n", "To Kara's astonishment, she discovers that a p... | \n", "2009 | \n", "Seven Seas | \n", "[19158] | \n", "[948696, 439885, 274955, 12978730, 372986, 216... | \n", "
| 6 | \n", "287149 | \n", "The Devil's Notebook | \n", "Wisdom, humor, and dark observations by the fo... | \n", "2000 | \n", "Feral House | \n", "[2983296, 40075] | \n", "[287151, 1104760, 1172822, 440292, 287082, 630... | \n", "
| \n", " | book_id | \n", "genres | \n", "
|---|---|---|
| 0 | \n", "5333265 | \n", "[history, historical fiction, biography] | \n", "
| 1 | \n", "1333909 | \n", "[history, historical fiction, biography] | \n", "
| 2 | \n", "7327624 | \n", "[fantasy, paranormal, mystery, thriller, crime... | \n", "
| 3 | \n", "6066819 | \n", "[romance, mystery, thriller, crime] | \n", "
| 4 | \n", "287141 | \n", "[history, historical fiction, biography, child... | \n", "
| \n", " | book_id | \n", "title | \n", "description | \n", "publication_year | \n", "publisher | \n", "authors | \n", "similar_books | \n", "genres | \n", "
|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1333909 | \n", "Good Harbor | \n", "Anita Diamant's international bestseller \"The ... | \n", "2001 | \n", "Simon & Schuster Audio | \n", "[626222] | \n", "[8709549, 17074050, 28937, 158816, 228563, 112... | \n", "[history, historical fiction, biography] | \n", "
| 1 | \n", "7327624 | \n", "The Unschooled Wizard (Sun Wolf and Starhawk, ... | \n", "Omnibus book club edition containing the Ladie... | \n", "1987 | \n", "Nelson Doubleday, Inc. | \n", "[10333] | \n", "[19997, 828466, 1569323, 425389, 1176674, 2627... | \n", "[fantasy, paranormal, mystery, thriller, crime... | \n", "
| 2 | \n", "6066819 | \n", "Best Friends Forever | \n", "Addie Downs and Valerie Adler were eight when ... | \n", "2009 | \n", "Atria Books | \n", "[9212] | \n", "[6604176, 6054190, 2285777, 82641, 7569453, 70... | \n", "[romance, mystery, thriller, crime] | \n", "
| 3 | \n", "6066812 | \n", "All's Fairy in Love and War (Avalon: Web of Ma... | \n", "To Kara's astonishment, she discovers that a p... | \n", "2009 | \n", "Seven Seas | \n", "[19158] | \n", "[948696, 439885, 274955, 12978730, 372986, 216... | \n", "[fantasy, paranormal, young-adult, children] | \n", "
| 4 | \n", "287149 | \n", "The Devil's Notebook | \n", "Wisdom, humor, and dark observations by the fo... | \n", "2000 | \n", "Feral House | \n", "[2983296, 40075] | \n", "[287151, 1104760, 1172822, 440292, 287082, 630... | \n", "[history, historical fiction, biography] | \n", "
| \n", " | author | \n", "count | \n", "
|---|---|---|
| 18 | \n", "123715 | \n", "2000 | \n", "
| 9 | \n", "3389 | \n", "1739 | \n", "
| 359 | \n", "3780 | \n", "1544 | \n", "
| 2111 | \n", "947 | \n", "1418 | \n", "
| 1534 | \n", "625 | \n", "1209 | \n", "
| \n", " | book_id | \n", "title | \n", "description | \n", "publication_year | \n", "publisher | \n", "authors | \n", "similar_books | \n", "genres | \n", "
|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1333909 | \n", "Good Harbor | \n", "Anita Diamant's international bestseller \"The ... | \n", "2001 | \n", "simon & schuster audio | \n", "[626222] | \n", "[8709549, 17074050, 28937, 158816, 228563, 112... | \n", "[history, historical fiction, biography] | \n", "
| 1 | \n", "7327624 | \n", "The Unschooled Wizard (Sun Wolf and Starhawk, ... | \n", "Omnibus book club edition containing the Ladie... | \n", "1987 | \n", "nelson doubleday, inc. | \n", "[10333] | \n", "[19997, 828466, 1569323, 425389, 1176674, 2627... | \n", "[fantasy, paranormal, mystery, thriller, crime... | \n", "
| 2 | \n", "6066819 | \n", "Best Friends Forever | \n", "Addie Downs and Valerie Adler were eight when ... | \n", "2009 | \n", "atria books | \n", "[9212] | \n", "[6604176, 6054190, 2285777, 82641, 7569453, 70... | \n", "[romance, mystery, thriller, crime] | \n", "
| 3 | \n", "6066812 | \n", "All's Fairy in Love and War (Avalon: Web of Ma... | \n", "To Kara's astonishment, she discovers that a p... | \n", "2009 | \n", "seven seas | \n", "[19158] | \n", "[948696, 439885, 274955, 12978730, 372986, 216... | \n", "[fantasy, paranormal, young-adult, children] | \n", "
| 4 | \n", "287149 | \n", "The Devil's Notebook | \n", "Wisdom, humor, and dark observations by the fo... | \n", "2000 | \n", "feral house | \n", "[2983296, 40075] | \n", "[287151, 1104760, 1172822, 440292, 287082, 630... | \n", "[history, historical fiction, biography] | \n", "
| \n", " | book_id | \n", "title | \n", "description | \n", "publication_year | \n", "publisher | \n", "authors | \n", "similar_books | \n", "genres | \n", "
|---|---|---|---|---|---|---|---|---|
| 0 | \n", "1333909 | \n", "Good Harbor | \n", "Anita Diamant's international bestseller \"The ... | \n", "2001 | \n", "simon & schuster audio | \n", "[626222] | \n", "[8709549, 17074050, 28937, 158816, 228563, 112... | \n", "['history, historical fiction, biography'] | \n", "
| 1 | \n", "7327624 | \n", "The Unschooled Wizard (Sun Wolf and Starhawk, ... | \n", "Omnibus book club edition containing the Ladie... | \n", "1987 | \n", "nelson doubleday, inc. | \n", "[10333] | \n", "[19997, 828466, 1569323, 425389, 1176674, 2627... | \n", "['fantasy, paranormal', 'mystery, thriller, cr... | \n", "
| 2 | \n", "6066819 | \n", "Best Friends Forever | \n", "Addie Downs and Valerie Adler were eight when ... | \n", "2009 | \n", "atria books | \n", "[9212] | \n", "[6604176, 6054190, 2285777, 82641, 7569453, 70... | \n", "['romance', 'mystery, thriller, crime'] | \n", "
| 3 | \n", "6066812 | \n", "All's Fairy in Love and War (Avalon: Web of Ma... | \n", "To Kara's astonishment, she discovers that a p... | \n", "2009 | \n", "seven seas | \n", "[19158] | \n", "[948696, 439885, 274955, 12978730, 372986, 216... | \n", "['fantasy, paranormal', 'young-adult', 'childr... | \n", "
| 4 | \n", "287149 | \n", "The Devil's Notebook | \n", "Wisdom, humor, and dark observations by the fo... | \n", "2000 | \n", "feral house | \n", "[2983296, 40075] | \n", "[287151, 1104760, 1172822, 440292, 287082, 630... | \n", "['history, historical fiction, biography'] | \n", "