CS229 Final Project — Stanford University | Sue Deng & Lea Wang-Tomic
A machine learning system that predicts how users will rate products in a new category based on their review history in another. Rather than recommending within a single category, this project uncovers cross-category behavioral patterns to enable deeper personalization.
Using Amazon review data from the Beauty and Fashion categories, the system trains on Fashion reviews and predicts Beauty ratings — then surfaces the top 5 recommended products per user.
| Model | RMSE |
|---|---|
| Linear Regression (baseline) | 0.9220 |
| KNN (baseline) | 0.9219 |
| Linear Regression (w/ feature engineering) | 0.1949 |
| KNN (w/ feature engineering) | 0.1859 ✅ |
| Content-Based Filtering | 0.1912 |
| Collaborative Filtering | 0.7589 |
| Hybrid Filtering | 0.2113 |
Best model: KNN with feature engineering (RMSE: 0.1859)
- Source: 2023 Amazon Reviews Dataset
- Categories: Beauty & Fashion (highest cross-category user overlap)
- Overlap: 116,428 users shared across both categories (~18.4% of Beauty users, ~5.7% of Fashion users)
- Training set: 3,431 user-product pairs (Fashion)
- Test set: 4,651 user-product pairs (Beauty)
- Filtered to users with above-median review counts to reduce sparsity
- Retained top 1,000 most-reviewed products per category
- Verified zero product overlap between categories
| Feature | Description |
|---|---|
user_average_rating |
Mean rating given by the user |
user_std_rating |
Standard deviation of user ratings |
avg_user_sentiment_title |
TextBlob sentiment score of review titles |
avg_user_sentiment_text |
TextBlob sentiment score of review bodies |
user_review_count |
Total number of reviews written |
helpfulness_ratio |
Ratio of helpful votes to total reviews |
| Feature | Description |
|---|---|
product_title_length |
Word count of the product title |
rating_number |
Total number of reviews for the product |
average_rating |
Mean product rating |
description_sentiment |
TextBlob sentiment score of product description |
Key finding: User behavior features (especially
user_average_ratinganduser_std_rating) were the strongest predictors — outperforming all product-specific attributes.
- Linear Regression — baseline continuous rating prediction
- K-Nearest Neighbors — similarity-based prediction; optimal at k=12 with uniform weighting and Euclidean distance
- Collaborative Filtering — cosine similarity across user-item interactions (limited by data sparsity)
- Content-Based Filtering — dot product between user preference vectors and item feature vectors
- Hybrid Model — combined collaborative + content-based filtering
.
├── data/
│ ├── raw/ # Raw Amazon review data
│ └── processed/ # Filtered and normalized datasets
├── features/
│ └── feature_engineering.py # TextBlob sentiment, user/product feature construction
├── models/
│ ├── baseline.py # Linear Regression & KNN baselines
│ ├── collaborative.py # Collaborative filtering (Surprise library)
│ ├── content_based.py # Content-based filtering
│ └── hybrid.py # Hybrid model
├── evaluation/
│ └── metrics.py # RMSE computation and residual analysis
├── notebooks/
│ └── analysis.ipynb # EDA, feature importance, result visualizations
└── README.md
git clone https://github.com/<your-username>/cross-category-recommender.git
cd cross-category-recommender
pip install -r requirements.txt- Python 3.9+
- scikit-learn
- pandas / numpy
- textblob
- scikit-surprise
- matplotlib / seaborn
# Run feature engineering
python features/feature_engineering.py
# Train and evaluate all models
python models/baseline.py
python models/collaborative.py
python models/content_based.py
python models/hybrid.py- Feature engineering matters more than model complexity. Simple KNN with well-engineered features beat all filtering approaches.
- User behavior > item attributes. A user's rating habits are the strongest signal for cross-category prediction.
- Collaborative filtering struggles with sparse cross-category data. Cold-start and sparsity issues significantly hurt performance (RMSE: 0.7589).
- Simpler is better here. Complex hybrid models didn't outperform well-tuned KNN.
- Advanced NLP (BERT/sentence embeddings) for richer sentiment features
- Neural Collaborative Filtering
- Two-Tower Models (DAT architecture) for large-scale deployment
- Expanding to additional Amazon category pairs
- Linden, G., Smith, B., York, J. (2003). Amazon.com Recommendations: Item-to-Item Collaborative Filtering. IEEE Internet Computing.
- Rendle, S. (2010). Factorization Machines. ICDM.
- Roy, D., Dutta, M. (2022). A Systematic Review on Recommender Systems. Journal of Big Data.
- Yu et al. (2021). A Dual Augmented Two-Tower Model for Online Large-Scale Recommendation. DLP-KDD.
Sue Deng — Data cleaning, feature engineering, data visualization, paper sections 1–4
Lea Wang-Tomic — Model training, evaluation, data visualization, paper sections 4–6
Stanford University, CS229 — December 2024