A sophisticated hybrid recommendation system that combines collaborative filtering and content-based filtering to deliver personalized anime recommendations
|
|
|
|
graph TD
A[Raw Data] --> B[Data Ingestion]
B --> C[Preprocessing]
C --> D[Feature Engineering]
D --> E[Model Training]
E --> F[Model Evaluation]
F --> G[Model Registry]
G --> H[FastAPI Service]
H --> I[Render Deployment]
J[DVC] --> B
K[Comet ML] --> E
L[GitHub] --> I
anime-recommender/
β
βββ π data/ # Dataset management
β βββ raw/ # Original datasets
β βββ processed/ # Cleaned datasets
β βββ features/ # Engineered features
β
βββ π notebooks/ # Research & experimentation
β βββ eda.ipynb # Exploratory data analysis
β βββ modeling.ipynb # Model development
β βββ evaluation.ipynb # Performance analysis
β
βββ π§ src/ # Source code
β βββ ingestion/ # Data loading pipelines
β βββ processing/ # Data preprocessing
β βββ model/ # ML model implementations
β βββ prediction/ # Inference pipelines
β βββ utils/ # Helper functions
β
βββ π app/ # Web application
β βββ main.py # FastAPI application
β βββ models.py # Pydantic models
β βββ templates/ # HTML templates
β
βββ π³ docker/ # Containerization
βββ π requirements.txt # Python dependencies
βββ π dvc.yaml # DVC pipeline configuration
βββ βοΈ .render.yaml # Render deployment config
βββ π README.md # Project documentation
- Python 3.8+
- Git
- DVC (optional, for data versioning)
-
Clone the repository
git clone https://github.com/yourusername/anime-recommender.git cd anime-recommender
-
Create virtual environment
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Run the application
uvicorn app.main:app --reload
-
Visit the API
http://localhost:8000
POST /recommend
Request Body:
{
"user_id": 123,
"num_recommendations": 5
}
Response:
{
"user_id": 123,
"recommendations": [
{
"anime_id": 5114,
"title": "Fullmetal Alchemist: Brotherhood",
"score": 9.1,
"genres": ["Action", "Adventure", "Drama"]
},
{
"anime_id": 1535,
"title": "Death Note",
"score": 8.9,
"genres": ["Supernatural", "Thriller"]
}
],
"generated_at": "2025-06-22T10:30:00Z"
}
GET /health
Response:
{
"status": "healthy",
"version": "1.0.0",
"model_version": "v2.1.0"
}
Category | Technologies |
---|---|
π€ Machine Learning | |
π Backend | |
π MLOps | |
βοΈ Cloud & Deployment | |
π§ DevOps |
Metric | Collaborative Filtering | Content-Based | Hybrid Model |
---|---|---|---|
RMSE | 0.87 | 0.92 | 0.82 |
MAE | 0.68 | 0.73 | 0.64 |
Precision@5 | 0.74 | 0.71 | 0.78 |
Recall@5 | 0.69 | 0.67 | 0.73 |
# Start development server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# Build image
docker build -t anime-recommender .
# Run container
docker run -p 8000:8000 anime-recommender
The application is configured for automatic deployment on Render using .render.yaml
:
services:
- type: web
name: anime-recommender-api
env: python
buildCommand: pip install -r requirements.txt
startCommand: uvicorn app.main:app --host 0.0.0.0 --port 10000
plan: free
# Run complete pipeline
dvc repro
# Track experiments
dvc exp run
# Push data to remote
dvc push
- Data Ingestion - Load and validate raw data
- Preprocessing - Clean and transform data
- Feature Engineering - Create model features
- Training - Train recommendation models
- Evaluation - Assess model performance
- Deployment - Deploy best model to production
The system uses anime rating data with the following structure:
- Users: 73,515 unique users
- Anime: 12,294 unique anime titles
- Ratings: 7,813,737 user-anime ratings
- Features: Genres, studios, year, episode count
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
pytest
# Run linting
flake8 src/
# Format code
black src/
This project is licensed under the MIT License - see the LICENSE file for details.
- MyAnimeList for providing the anime dataset
- Comet ML for experiment tracking capabilities
- Render for free-tier cloud deployment
- DVC for seamless data version control
- FastAPI community for excellent documentation
- Surprise library for collaborative filtering algorithms