Skip to content

Finnwindhoek/anime-recommender-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

20 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽŒ Anime Recommender System โญ

Anime Banner

๐Ÿ›  Tech Stack

Python Streamlit scikit-learn Surprise Pandas NumPy

Otaku Alert! ๐Ÿš€ This notebook is your ultimate weapon for discovering hidden anime gems, powered by AI! Like a Sharingan scanning for chakra signatures, we'll use:

  • Content-Based Filtering: Matches anime by genres (e.g., if you love 'Dragon Ball', youโ€™ll get action-packed titles!).
  • Collaborative Filtering: Learns from user ratings (what would L recommend to Light?).
  • Hybrid Approach: Combines both for ultimate power-ups! ๐Ÿ’ฅ

Rate some anime, choose your favorite and let the recommendations flow like chakra!

Kon'nichiwa, User! Rate at least 5 anime to unlock personalized recs. Demo mode uses sampled data for speed. Let's go! ๐ŸŽ‰


๐Ÿ“‘ Table of Contents


โœจ Demo

Click to try the Live App ๐Ÿ‘‰ Anime Recommendation System Live


๐Ÿ“Š About the Dataset

This project is powered by the comprehensive Anime Recommendations Database from Kaggle, which was originally scraped from MyAnimeList.net. It provides the two critical scrolls of data needed to train a sophisticated hybrid model.

๐Ÿ“œ anime.csv โ€” The Encyclopedia of Anime

This file is the metadata catalog, containing information on 12,294 unique anime. It's the primary fuel for the Content-Based model, allowing it to understand what an anime is about.

  • Key Columns: anime_id, name, genre, type, rating

๐Ÿ“ˆ rating.csv โ€” The Collective Will of the Fans

This file contains the raw power of crowd wisdom: 7.8 million ratings from 73,516 users. This massive user-item interaction matrix is the essential fuel for the Collaborative Filtering (SVD) engine, allowing it to learn what fans actually think.

  • Key Columns: user_id, anime_id, rating

โžก๏ธ Source: Anime Recommendations Database on Kaggle


๐ŸŒณ Directory Tree

anime-recommender-system/
โ”œโ”€โ”€ .streamlit/
โ”‚   โ””โ”€โ”€ config.toml
โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ anime.csv
โ”œโ”€โ”€ rating.csv
โ”œโ”€โ”€ packages.txt
โ””โ”€โ”€ requirements.txt

๐Ÿ“‚ Repository Structure

Hereโ€™s a breakdown of the key files and what they do:

File Purpose
app.py ๐Ÿš€ The heart of the operation! This single script contains all the Streamlit UI code, data processing functions, and the recommendation algorithms. Run this file to launch the app.
anime.csv ๐Ÿ“œ The Anime Encyclopedia. This dataset holds all the metadata for thousands of anime titles, including their genres, type, and community ratings. Powers the Content-Based model.
rating.csv ๐Ÿ“Š The Scroll of User Jutsus. Contains millions of user ratings, forming the massive user-item interaction matrix. This is the fuel for the Collaborative Filtering (SVD) engine.
requirements.txt
packages.txt
.streamlit/config.toml
โš™๏ธ The Deployment Spellbook. This collection of files provides the critical instructions for Streamlit Community Cloud, defining the exact Python version, system-level packages (like C++ compilers), and Python libraries needed to build and run the application successfully.

โš™๏ธ Installation & Local Setup

Want to run the Anime Recommender on your own machine? No problem! Here are two ways to get the project set up on Windows.


Method 1: Using Git Method

This is the recommended method if you're comfortable with the command line. It makes getting updates super easy.

1. Install Git: If you don't have Git, download and install it from the official website. The default settings are fine. โžก๏ธ git-scm.com/downloads

2. Clone the Repository: Open your command prompt (cmd) or terminal and run the following commands:

# Clone the repository to your computer
git clone https://github.com/Finnwindhoek/anime-recommender-system.git
# Navigate into the newly created project folder
cd anime-recommender-system

Method 2: Manual Download

No command line needed for this.

1. Go to the GitHub Repository: โžก๏ธ github.com/Finnwindhoek/anime-recommender-system

2. Download the ZIP file: Click the green < > Code button, then click "Download ZIP".

3. Unzip the folder: Find the downloaded anime-recommender-system-main.zip file in your Downloads folder and unzip/extract it to a location you'll remember (like your Desktop).


๐Ÿ’ป Running the Application (For Both Methods)

  • Click WinKey and search for "cmd " and enter python --version

Note: If python not installed, install python (version: 3.9 - 3.11)- https://www.python.org/downloads/windows/


Step 2: After installation Completed.

  • Open miniconda prompt.
  • Create enviroment with Python 3.10.11
conda create -n ai_env python=3.10.11
  • Activate the python enviroment
conda activate ai_env
  • Navigate to Anime Recommender System (Streamlit)
cd C:\Users\File Directory\anime recommender system

Install command for packages:
conda install -c conda-forge scikit-learn scikit-surprise -y
pip install -r requirements.txt

After package installations, run streamlit run app.py to run the code and start the model.


๐Ÿง‘โ€๐Ÿ’ป Code Walkthrough

The entire application is powered by a single, comprehensive script: app.py. Hereโ€™s a high-level breakdown of its architecture and logic.

1. The Ninja's Arsenal: Imports & Configuration ๐Ÿงฐ

The script begins by importing all the necessary librariesโ€”our "ninja tools"โ€”including Streamlit for the UI, Pandas for data handling, Scikit-learn for content-based logic, and Surprise for the collaborative engine. Key global variables like REQUIRED_RATINGS and DEMO_MODE are also set here, allowing for easy configuration.

2. Summoning the Scrolls: Data Loading & Caching ๐Ÿ“œ

To ensure the app is fast and responsive, all data loading and heavy computations are cached using Streamlit's powerful decorators:

  • @st.cache_data: Used for loading the CSV files (anime.csv, rating.csv). This ensures the data is loaded from disk only once, making subsequent runs instantaneous.
  • @st.cache_resource: Used for building the resource-intensive similarity matrix and training the SVD models. This keeps these heavy objects in memory, preventing them from being recalculated on every user interaction.

3. The Three Great Jutsus: The Core Algorithms ๐Ÿ’ฅ

This is the heart of the recommender system, where the three distinct recommendation methods are defined as functions:

  • get_content_recs(): Implements the Content-Based model. It takes a user's favorite anime, finds its vector in the pre-computed TF-IDF Cosine Similarity matrix, and returns the most similar anime.
  • get_collab_recs(): Powers the Collaborative Filtering model. It takes the user's current ratings, adds them to the main dataset, trains a personalized SVD model on the fly, and predicts ratings for all unseen anime to find the top recommendations.
  • get_hybrid_recs(): The "Sage Mode" of the app. It calls the other two functions to get two separate lists of candidates, then merges and re-ranks them using a custom hybrid_score to produce a final list that is the best of both worlds.

4. The Power Level Scanner: Performance Evaluation โšก

The calculate_evaluation_metrics() function is a standout feature. It takes a user's ratings, performs a train/test split, and trains a temporary SVD model to evaluate its predictive accuracy. This function calculates the RMSE, Precision, Recall, and F1-Score, powering the real-time "System Evaluation" tab and providing direct insight into the model's performance.

5. The Mission Control Center: The Streamlit UI ๐ŸŽฎ

The final part of the script contains the main application logic. It uses Streamlit commands (st.selectbox, st.button, st.tabs, etc.) to draw the entire user interface. A key feature here is the use of st.session_state, which acts as the app's memory. It's used to store the user's ratings across multiple interactions, allowing for a stateful and personalized experience without needing a database.


๐ŸžBug / โœจ Feature Request

Spotted a glitch in the matrix or have an idea for a Super Saiyan-level upgrade? I'd love to hear from you! The best way to get in touch is by opening an issue on this repository's GitHub page.

Open a New Issue

Reporting a Bug ๐Ÿ›

If you find a bug, please include the following to help me squash it:

  • A clear and descriptive title.
  • Steps to reproduce the bug.
  • What you expected to happen.
  • What actually happened (screenshots are a huge help!).

Suggesting a Feature โœจ

If you have an idea for a new feature:

  • A clear and descriptive title.
  • A detailed description of the proposed feature.
  • Explain why this feature would be a great addition to the recommender!

๐Ÿ”ฎ Future Work

The current system is a powerful Shounen protagonist, but there's always a new form to unlock! Here are some of the potential power-ups for the next season:

  • ๐Ÿง  Deeper Content Analysis with NLP Go beyond simple genre tags. The next step is to implement advanced NLP models (like BERT or Sentence Transformers) to analyze anime synopses, reviews, and fan tags. This would allow the system to understand nuanced themes like "dystopian world-building" or "morally grey protagonist," leading to incredibly insightful content-based recommendations.

  • ๐ŸŒ Real-Time API Integration Keep the database fresh! Integrate with APIs like AniList or MyAnimeList (Jikan) to automatically fetch new anime releases, updated ratings, and seasonal charts. This would transform the app from a static snapshot into a living, breathing recommendation platform.

  • ๐Ÿ‘ค Personalized User Profiles Allow users to create accounts to save their ratings, view their watch history, and create custom watchlists. This is the foundation for a truly long-term personalized experience where the model can learn and adapt to a user's evolving tastes over time.

  • ๐Ÿ“ˆ Advanced Visualizations & Explainability Show the user why they're getting a recommendation. Add interactive charts (using Plotly or Altair) to visualize a user's genre preferences, rating distribution, and how a recommendation connects to their taste profile. This builds trust and makes the system's "thinking" more transparent.

  • ๐Ÿ“ฑ Mobile App Deployment Take the recommender on the go! Package the system into a mobile app using a framework like React Native or Flutter, providing a seamless and accessible experience for users on any device.

About

A hybrid Anime Recommendation System that combines Content-Based Filtering and Collaborative Filtering (SVD) to deliver accurate, diverse, and personalized anime suggestions.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages