Book-Recommendation-system
A book recommendation system is a type of recommender system that suggests books to users based on their preferences and past behavior. The goal of a book recommendation system is to help users discover new books that they might be interested in reading.
- EDA
Book-Recommendation-system Project. To build a book recommendation system, you need a large dataset of books, their authors, genres, descriptions, ratings, and any other relevant information. You also need to preprocess the data to clean it and convert categorical variables to numerical ones. Then you choose an appropriate algorithm, such as content-based filtering or collaborative filtering, and train your model on the preprocessed dataset.
Collect a dataset of books, their authors, genres, descriptions, ratings, and any other relevant information that will help you build a recommendation system.
import numpy as np
import pandas as pd
Clean the data and preprocess it for use in your recommendation system. This may include tasks such as removing duplicates, filling in missing values, and converting categorical variables to numerical ones.
Popularity Based Recommender System
Collaborative Filtering Based Recommender System
There are many recommendation algorithms to choose from, such as content-based filtering, collaborative filtering, and matrix factorization. Choose the one that best fits your needs.
from sklearn.metrics.pairwise import cosine_similarity
Train your recommendation system on your preprocessed dataset using the chosen algorithm.
import pickle
pickle.dump(pt,open('pt.pkl','wb'))
pickle.dump(book,open('books.pkl','wb'))
pickle.dump(similarity_scores,open('similarity.pkl','wb'))
Then install the project dependencies with
pip install -r requirements.txt
Load the trained machine learning model into your Flask application. You can use a library like pickle to serialize your model and save it to disk, then load it into your Flask application when it starts up.
import pickle
from flask import Flask, request, render_template
# Load the trained model from disk
with open('model.pkl', 'rb') as f:
model = pickle.load(f)
# Create a new Flask application
app = Flask(__name__)
# Define a route for book recommendations
@app.route('/recommend')
def recommend_books():
# Get user input from the request arguments
title = request.args.get('title')
author = request.args.get('author')
# Use the model to generate recommendations
recommendations = model.predict(title, author)
# Render the recommendations as HTML output
return render_template('recommendations.html', recommendations=recommendations)
# Run the Flask application
if __name__ == '__main__':
app.run(debug=True)
Data link:
https://www.kaggle.com/datasets/arashnic/book-recommendation-dataset
To build a book recommendation system, you need a large dataset of books, their authors, genres, descriptions, ratings, and any other relevant information. You also need to preprocess the data to clean it and convert categorical variables to numerical ones. Then you choose an appropriate algorithm, such as content-based filtering or collaborative filtering, and train your model on the preprocessed dataset.
Once your model is trained, you can build a user interface that allows users to input their preferences and see book recommendations based on those preferences. This user interface can be built using a web framework like Flask, and can be deployed on a cloud service like Heroku.
Overall, a book recommendation system can be a powerful tool for helping users discover new books and improving their reading experience.
Light Mode |
Dark Mode |