An open API service indexing awesome lists of open source software.

https://github.com/nomomon/anime-recsys

:film_strip: Development and comparison of user-item recommendation systems in TensorFlow on an anime dataset.
https://github.com/nomomon/anime-recsys

anime collaborative-filtering content-based-recommendation deep-learning keras machine-learning matrix-factorization neural-network recommendation-system recommender-system recsys tensorflow tf-recsys

Last synced: 2 months ago
JSON representation

:film_strip: Development and comparison of user-item recommendation systems in TensorFlow on an anime dataset.

Awesome Lists containing this project

README

          

# Anime RecSys

![banner](./assets/banner.png)

[![](https://img.shields.io/badge/-Open%20Drive-4285F4?style=flat&logo=Google%20Drive&logoColor=white&labelColor=5c5c5c)](https://drive.google.com/drive/folders/1lUwT4v3Uji4JCMmjU4_qEpBQ2yl8HrYc)
[![license](https://img.shields.io/github/license/nomomon/Anime-RecSys)](/LICENSE)

Development and comparison of user-item recommendation systems in TensorFlow on an anime dataset.

## What's this about

Building recommendation systems using collaborative filtering on the [Anime Recommendation Database 2020](https://www.kaggle.com/hernan4444/anime-recommendation-database-2020) from Kaggle. All models can be downloaded from the Drive.

There are two common ways of recommending:
- **Collaborative filtering** — predictions based on collected preferences from many users.
- **Content-based filtering** — predictions based on item descriptions and user profiles.

Right now we focus only on collaborative filtering.

### Results

**Rating prediction:**

| Model | val_loss | RMSE |
|---|---|---|
| Hybrid NN | 1.9694 | 1.4034 |
| Neural Network | 1.9897 | 1.4105 |
| Matrix Factorization | 2.8429 | 1.6861 |

**Interaction prediction:**

| Model | val_loss | Acc | Precision | Recall |
|---|---|---|---|---|
| Hybrid NN | 0.3079 | 0.8790 | 0.8931 | 0.9759 |
| Neural Network | 0.2502 | 0.8050 | 0.8907 | 0.8282 |
| Matrix Factorization | 0.4691 | 0.7678 | 0.8969 | 0.7621 |

The hybrid model wins on most metrics — multi-task learning helps.

## How to launch

Open notebooks in Jupyter or Google Colab:

```bash
jupyter notebook User_Anime_Rating_Predictions.ipynb
```

Pre-trained models available on [Google Drive](https://drive.google.com/drive/folders/1lUwT4v3Uji4JCMmjU4_qEpBQ2yl8HrYc).

## Predicting User-Anime Ratings

[![](https://img.shields.io/badge/-Open%20in%20GitHub-157aba?style=flat&logo=GitHub&logoColor=white&labelColor=5c5c5c)](/User_Anime_Rating_Predictions.ipynb)
[![Open In Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/nomomon/anime-recommendations/blob/master/User_Anime_Rating_Predictions.ipynb)

One way to recommend items is by predicting _what rating a user will give_, then showing the highest-rated unseen items.

### Matrix Factorization

Decompose the user-item interaction matrix into two lower-dimensional matrices. We never actually create the full rating matrix — instead we use embeddings.



### Neural Network

Concatenate user and item embeddings, pass through dense layers. Last layer outputs the predicted rating.



## Predicting User-Anime Interactions

[![](https://img.shields.io/badge/-Open%20in%20GitHub-157aba?style=flat&logo=GitHub&logoColor=white&labelColor=5c5c5c)](/User_Anime_Interactions_Predictions.ipynb)
[![Open In Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/nomomon/anime-recommendations/blob/master/User_Anime_Interactions_Predictions.ipynb)

Instead of predicting ratings, we can ask: _will the user have a positive interaction with this anime?_

Positive = completed + rated above 5. Negative = dropped or rated 5 or below. Same model structures, but with sigmoid on the output.

## Hybrid (Multi-task)

[![](https://img.shields.io/badge/-Open%20in%20GitHub-157aba?style=flat&logo=GitHub&logoColor=white&labelColor=5c5c5c)](/User_Anime_Hybrid_Predictions.ipynb)
[![Open In Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/nomomon/anime-recommendations/blob/master/User_Anime_Hybrid_Predictions.ipynb)

A model that handles both tasks — predicting ratings and interactions — using shared embeddings. The loss is a weighted sum of both task losses.