Skip to main content

A package for book recommendation.

Project description

Kitab - Book Recommendation System

Package Overview

The Kitab package aims to help bookstores with an easy-to-use recommendation system. When a customer requests a book that is currently unavailable, the system will utilize machine learning techniques to find similar books based on attributes such as genre, author, and book description. This will help bookstores enhance customer satisfaction and increase sales by offering relevant alternatives.

Package Name

The package name is Kitab, which is the word for book in Arabic, Swahili, Urdu, Hindi and various Indian and Turkic languages.

Getting Started

Installation

To install the package, run the following command:

pip install kitab

To upgrade the package, run the following command:

pip install kitab --upgrade

Requirements

Currently, the package only supports PostgreSQL databases. You need to have a PostgreSQL database installed on your machine to use the package.

Additionally, since the package needs to store vectors, pgvector should be installed. To install it, follow the steps mentioned in the pgvector documentation.

All other requirements will be installed when the package is installed/updated using pip.

Usage

To start using the package functionalities, you need to import the package in your Python script. Then you need to provide the book data, which should include the following columns:

  • isbn (str) - the ISBN of the book,
  • title (str) the title of the book,
  • description (str) the description of the book,
  • author (list[str]) - the authors of the book,
  • genre (list[str]) - the genres of the book,
  • available (bool) - whether the book is available or not (optional; you can use random initialization of this column).

The process_data() function will process the data and generate the embeddings (this might take a while). It will split the data into parts, generate embeddings, store them in a specified folder. The folder will have numbered CSVs with the processed data and PKLs with the embeddings.

from kitab.utils import process_data

filepath = "data.csv"
destination_folder = "data"

process_data(filepath, destination_folder)

Then you need to load these data into the database. For this, you need to provide the database connection details in your .env file as follows:

DB_USER='' # Database username
DB_PASSWORD='' # Database password
DB_HOST='' # Database host
DB_PORT='' # Database port
DB_NAME='' # Database name

Then using the load_data() function, the data can be loaded into the database. The function gets the path of the folder which stores the data and the embeddings, combine these, and load them into the database.

from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())

from kitab.db.get_data import load_data

load_data(destination_folder)

Then you're ready to use the package functionalities. You can use the recommend_books() function to get recommendations for a book. The function takes the ISBN of the book and the number of recommendations you want to get.

from kitab.recommendation_model.models import recommend_books

description = "In this thrilling detective tale, a group of childhood friends accidentally stumble upon an ancient artifact hidden in their clubhouse. Little do they know, their discovery thrusts them into a dangerous conspiracy spanning centuries. As they uncover clues, they race against time to prevent a cataclysmic event that could reshape the world. Join them on a heart-pounding journey through shadows and secrets in this gripping mystery."

recommend_books(description, n=5)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kitab-0.0.22.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

kitab-0.0.22-py3-none-any.whl (21.5 kB view details)

Uploaded Python 3

File details

Details for the file kitab-0.0.22.tar.gz.

File metadata

  • Download URL: kitab-0.0.22.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for kitab-0.0.22.tar.gz
Algorithm Hash digest
SHA256 f270568a161cd0cb2c0bbdbb26a64e91174a60e9886a1628d2c68102124458c5
MD5 d3f5ba57979184375c8cdcc61fb93c3a
BLAKE2b-256 16d57d83edc69f586056597af1030e2b1b234716cf4749ccd11c08c0eeb18577

See more details on using hashes here.

File details

Details for the file kitab-0.0.22-py3-none-any.whl.

File metadata

  • Download URL: kitab-0.0.22-py3-none-any.whl
  • Upload date:
  • Size: 21.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.9

File hashes

Hashes for kitab-0.0.22-py3-none-any.whl
Algorithm Hash digest
SHA256 a57967f0d8842d09bdf8bcb5fe6d03bd39a842a21a6ceb348c53a944dfd859b8
MD5 0c65b8a77fea658c9ba43285ccd395ce
BLAKE2b-256 bb0e377131b7886731a9adfc0adeee084e0b6d124e938782339587909011e8bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page