{"id":89620,"date":"2025-02-15T11:55:17","date_gmt":"2025-02-15T11:55:17","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/how-to-build-an-anime-recommendation-system\/"},"modified":"2025-02-15T11:55:17","modified_gmt":"2025-02-15T11:55:17","slug":"how-to-build-an-anime-recommendation-system","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=89620","title":{"rendered":"How to Build an Anime Recommendation System?"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div id=\"article-start\">\n<p>A few years ago, I fell into the world of anime from which I\u2019d never escape. As my watchlist was growing thinner and thinner, finding the next best anime became harder and harder. There are so many hidden gems out there, but how do I discover them? That\u2019s when I thought\u2014why not let Machine Learning sensei do the hard work? Sounds exciting, right?<\/p>\n<p>In our digital era, <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2021\/07\/recommendation-system-understanding-the-basic-concepts\/\" target=\"_blank\" rel=\"noopener\">recommendation systems<\/a> are the silent\u00a0entertainment\u00a0heroes that power our daily online experiences. Whether it involves suggesting television series, creating a personalized music playlist, or recommending products based on browsing history, these algorithms operate in the background to improve user engagement.<\/p>\n<p>This guide walks you through building a production-ready\u00a0anime recommendation engine that runs 24\/7 without the need for traditional cloud platforms. With hands-on use cases, code snippets, and a detailed exploration of the architecture, you\u2019ll be equipped to build and deploy your own recommendation engine.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-learning-objectives\">Learning Objectives<\/h2>\n<ul class=\"wp-block-list\">\n<li>Understand the entire data processing and model training workflows to ensure efficiency and scalability.<\/li>\n<li>Build and deploy an engaging user-friendly recommendation system on Hugging Face Spaces with a dynamic interface.<\/li>\n<li>Gain hands-on experience in developing end-to-end recommendation engines using machine learning approaches such as SVD, collaborative filtering and content-based filtering.<\/li>\n<li>Seamlessly containerize your project using Docker for consistent deployment across different environments.<\/li>\n<li>Combine various recommendation strategies within one interactive application to deliver personalized recommendations.<\/li>\n<\/ul>\n<p><em><strong>This article was published as a part of the\u00a0<\/strong><\/em><a href=\"https:\/\/www.analyticsvidhya.com\/datahack\/blogathon\" target=\"_blank\" rel=\"noreferrer noopener\"><em><strong>Data Science Blogathon.<\/strong><\/em><\/a><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-anime-recommendation-system-with-hugging-face-data-collection\">Anime Recommendation System with Hugging Face: Data Collection<\/h2>\n<p>The foundation of any <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2021\/07\/recommendation-system-understanding-the-basic-concepts\/\" target=\"_blank\" rel=\"noreferrer noopener\">recommendation system<\/a> lies in quality data. For this project, datasets were sourced from Kaggle and then stored in the Hugging Face Datasets Hub for streamlined access and integration. The primary datasets used include:<\/p>\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/huggingface.co\/datasets\/krishnaveni76\/Animes\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Animes<\/a>: A dataset detailing anime titles and associated metadata.<\/li>\n<li><a href=\"https:\/\/huggingface.co\/datasets\/krishnaveni76\/Anime_UserRatings\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Anime_UserRatings<\/a>: User rating data for each anime.<\/li>\n<li><a href=\"https:\/\/huggingface.co\/datasets\/krishnaveni76\/UserRatings\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">UserRatings<\/a>: General user ratings providing insights into viewing habits.<\/li>\n<\/ul>\n<h2 class=\"wp-block-heading\" id=\"h-pre-requisites-for-anime-recommendation-app\">Pre-requisites for Anime Recommendation App<\/h2>\n<p>Before we begin, ensure that you have completed the following steps:<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-1-sign-up-and-log-in\">1. Sign Up and Log In<\/h3>\n<ul class=\"wp-block-list\">\n<li>Go to <a href=\"https:\/\/huggingface.co\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Hugging Face<\/a> and create an account if you haven\u2019t already.<\/li>\n<li>Log in to your Hugging Face account to access the Spaces section.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-2-create-a-new-space\">2. Create a New Space<\/h3>\n<ul class=\"wp-block-list\">\n<li>Navigate to the \u201cSpaces\u201d section from your profile or dashboard.<\/li>\n<li>Click on the \u201cCreate New Space\u201d button.<\/li>\n<li>Provide a unique name for your space and choose the \u201cStreamlit\u201d option for the app interface.<\/li>\n<li>Set your space to public or private based on your preference.<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\" id=\"h-3-clone-the-space-repository\">3. Clone the Space Repository<\/h3>\n<ul class=\"wp-block-list\">\n<li>After creating the Space, you\u2019ll be redirected to the repository page for your new space.<\/li>\n<li>Clone the repository to your local machine using Git with the following command:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>git clone https:\/\/huggingface.co\/spaces\/your-username\/your-space-name<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-4-set-up-the-virtual-environment\">4. Set Up the Virtual Environment<\/h4>\n<ul class=\"wp-block-list\">\n<li>Navigate to your project directory and create a new virtual environment using Python\u2019s built-in venv tool.<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code># Creating the Virtual environment\n\n## For macOS and Linux:\npython3 -m venv env \n## For Windows:\npython -m venv env\n\n\n# Activation the environment\n\n## For macOS and Linux:\nsource env\/bin\/activate\n## For Windows:\n.\\env\\Scripts\\activate<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-5-install-dependencies\">5. Install Dependencies<\/h4>\n<ul class=\"wp-block-list\">\n<li>In the cloned repository, create a <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/requirements.txt\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">requirements.txt<\/a> file that lists all the dependencies your app requires (e.g., Streamlit, pandas, etc.).<\/li>\n<li>Install the dependencies using the command:<\/li>\n<\/ul>\n<pre class=\"wp-block-code\"><code>pip install -r requirements.txt<\/code><\/pre>\n<p>Before diving into the code, it is essential to understand how the various components of the system interact. Check out the below project architecture.<\/p>\n<figure class=\"wp-block-image size-full figure  mt-2 mb-2 d-table mx-auto\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1346\" height=\"777\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp\" alt=\"project architecture\" class=\"wp-image-221569\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp 1346w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539-300x173.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539-768x443.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539-150x87.webp 150w\" sizes=\"(max-width: 1346px) 100vw, 1346px\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-folder-structure\">Folder Structure<\/h2>\n<p>This project adopts a modular folder structure designed to align with industry standards, ensuring scalability and maintainability.<\/p>\n<pre class=\"wp-block-code\"><code>ANIME-RECOMMENDATION-SYSTEM\/              # Project directory\n\u251c\u2500\u2500 anime_recommender\/                    # Main package containing all the modules\n\u2502   \u2502\u2500\u2500 __init__.py                       # Package initialization\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 components\/                       # Core components of the recommendation system\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                   # Package initialization\n\u2502   \u2502   \u2502\u2500\u2500 collaborative_recommender.py  # Collaborative filtering model\n\u2502   \u2502   \u2502\u2500\u2500 content_based_recommender.py  # Content-based filtering model\n\u2502   \u2502   \u2502\u2500\u2500 data_ingestion.py             # Fetches and loads data\n\u2502   \u2502   \u2502\u2500\u2500 data_transformation.py        # Preprocesses and transforms the data\n\u2502   \u2502   \u2502\u2500\u2500 top_anime_recommenders.py     # Filters top animes\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 constant\/                   \n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                   # Stores constant values used across the project\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 entity\/                           # Defines structured entities like configs and artifacts\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                 \n\u2502   \u2502   \u2502\u2500\u2500 artifact_entity.py            # Data structures for model artifacts\n\u2502   \u2502   \u2502\u2500\u2500 config_entity.py              # Configuration parameters and settings\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 exception\/                        # Custom exception handling\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                    \n\u2502   \u2502   \u2502\u2500\u2500 exception.py                  # Handles errors and exceptions\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 loggers\/                          # Logging and monitoring setup\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                    \n\u2502   \u2502   \u2502\u2500\u2500 logging.py                    # Configures log settings\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 model_trainer\/                    # Model training scripts\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py              \n\u2502   \u2502   \u2502\u2500\u2500 collaborative_modelling.py    # Train collaborative filtering model\n\u2502   \u2502   \u2502\u2500\u2500 content_based_modelling.py    # Train content-based model\n\u2502   \u2502   \u2502\u2500\u2500 top_anime_filtering.py        # Filters top animes based on ratings\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 pipelines\/                        # End-to-end ML pipelines\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                    \n\u2502   \u2502   \u2502\u2500\u2500 training_pipeline.py          # Training pipeline\n\u2502   \u2502\n\u2502   \u251c\u2500\u2500 utils\/                            # Utility functions\n\u2502   \u2502   \u2502\u2500\u2500 __init__.py                   \n\u2502   \u2502   \u251c\u2500\u2500 main_utils\/\n\u2502   \u2502   \u2502   \u2502\u2500\u2500 __init__.py                \n\u2502   \u2502   \u2502   \u2502\u2500\u2500 utils.py                  # Utility functions for specific processing\n\u251c\u2500\u2500 notebooks\/                            # Jupyter notebooks for EDA and experimentation\n\u2502   \u251c\u2500\u2500 EDA.ipynb                         # Exploratory Data Analysis\n\u2502   \u251c\u2500\u2500 final_ARS.ipynb                   # Final implementation notebook               \n\u251c\u2500\u2500 .gitattributes                        # Git configuration for handling file formats\n\u251c\u2500\u2500 .gitignore                            # Specifies files to ignore in version control\n\u251c\u2500\u2500 app.py                                # Main Streamlit app \n\u251c\u2500\u2500 Dockerfile                            # Docker configuration for containerization\n\u251c\u2500\u2500 README.md                             # Project documentation\n\u251c\u2500\u2500 requirements.txt                      # Dependencies and libraries\n\u251c\u2500\u2500 run_pipeline.py                       # Runs the entire training pipeline\n\u251c\u2500\u2500 setup.py                              # Setup script for package installation<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-constants\">Constants<\/h3>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/constant\/__init__.py\" target=\"_blank\" rel=\"nofollow noopener\">constant\/__init__.py<\/a> file defines all essential constants, such as file paths, directory names, and model filenames. These constants standardize configurations across the data ingestion, transformation, and model training stages. This ensures consistency, maintainability, and easy access to key project configurations.<\/p>\n<pre class=\"wp-block-code\"><code>\"\"\"Defining common constant variables for training pipeline\"\"\"\nPIPELINE_NAME: str = \"AnimeRecommender\"\nARTIFACT_DIR: str = \"Artifacts\"\nANIME_FILE_NAME: str = \"Animes.csv\"\nRATING_FILE_NAME:str = \"UserRatings.csv\"\nMERGED_FILE_NAME:str = \"Anime_UserRatings.csv\" \nANIME_FILE_PATH:str = \"krishnaveni76\/Animes\"\nRATING_FILE_PATH:str = \"krishnaveni76\/UserRatings\"\nANIMEUSERRATINGS_FILE_PATH:str = \"krishnaveni76\/Anime_UserRatings\"\nMODELS_FILEPATH = \"krishnaveni76\/anime-recommendation-models\"\n\n\"\"\"Data Ingestion related constant start with DATA_INGESTION VAR NAME\"\"\"  \nDATA_INGESTION_DIR_NAME: str = \"data_ingestion\"\nDATA_INGESTION_FEATURE_STORE_DIR: str = \"feature_store\"\nDATA_INGESTION_INGESTED_DIR: str = \"ingested\"\n\n\"\"\"Data Transformation related constant start with DATA_VALIDATION VAR NAME\"\"\"\nDATA_TRANSFORMATION_DIR:str = \"data_transformation\"\nDATA_TRANSFORMATION_TRANSFORMED_DATA_DIR:str = \"transformed\" \n\n\"\"\"Model Trainer related constant start with MODEL TRAINER VAR NAME\"\"\" \nMODEL_TRAINER_DIR_NAME: str = \"trained_models\"\n\nMODEL_TRAINER_COL_TRAINED_MODEL_DIR: str = \"collaborative_recommenders\"\nMODEL_TRAINER_SVD_TRAINED_MODEL_NAME: str = \"svd.pkl\"\nMODEL_TRAINER_ITEM_KNN_TRAINED_MODEL_NAME: str = \"itembasedknn.pkl\"\nMODEL_TRAINER_USER_KNN_TRAINED_MODEL_NAME: str = \"userbasedknn.pkl\"\n\nMODEL_TRAINER_CON_TRAINED_MODEL_DIR:str = \"content_based_recommenders\"\nMODEL_TRAINER_COSINESIMILARITY_MODEL_NAME:str = \"cosine_similarity.pkl\"<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-utils\">Utils<\/h3>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/utils\/main_utils\/utils.py\" target=\"_blank\" rel=\"nofollow noopener\">utils\/main_utils\/utils.py<\/a> file contains utility functions for operations such as saving\/loading data, exporting dataframes, saving models, and uploading models to Hugging Face. These reusable functions streamline processes throughout the project.<\/p>\n<pre class=\"wp-block-code\"><code>def export_data_to_dataframe(dataframe: pd.DataFrame, file_path: str) -&gt; pd.DataFrame: \n    dir_path = os.path.dirname(file_path)\n    os.makedirs(dir_path, exist_ok=True)\n    dataframe.to_csv(file_path, index=False, header=True) \n    return dataframe \n\ndef load_csv_data(file_path: str) -&gt; pd.DataFrame: \n    df = pd.read_csv(file_path) \n    return df  \n\ndef save_model(model: object, file_path: str) -&gt; None: \n    os.makedirs(os.path.dirname(file_path), exist_ok=True)\n    with open(file_path, \"wb\") as file_obj:\n        joblib.dump(model, file_obj) \n\ndef load_object(file_path: str) -&gt; object: \n    if not os.path.exists(file_path):\n        error_msg = f\"The file: {file_path} does not exist.\" \n        raise Exception(error_msg)\n    with open(file_path, \"rb\") as file_obj: \n        return joblib.load(file_obj) \n    \ndef upload_model_to_huggingface(model_path: str, repo_id: str, filename: str): \n    api = HfApi()\n    api.upload_file(path_or_fileobj=model_path,path_in_repo=filename,=repo_id,repo_type=\"model\" ) <\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-configuration-nbsp-setup\">Configuration\u00a0Setup<\/h3>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/entity\/config_entity.py\" target=\"_blank\" rel=\"nofollow noopener\">entity\/config_entity.py<\/a> file holds configuration details for different stages of the training pipeline. This includes paths for data ingestion, transformation, and model training for both collaborative and content-based recommendation systems. These configurations ensure a structured and organized workflow throughout the project.<\/p>\n<pre class=\"wp-block-code\"><code>class TrainingPipelineConfig:\n    def __init__(self, timestamp=datetime.now()):\n        timestamp = timestamp.strftime(\"%m_%d_%Y_%H_%M_%S\")\n        self.pipeline_name = PIPELINE_NAME\n        self.artifact_dir = os.path.join(ARTIFACT_DIR, timestamp)\n        self.model_dir=os.path.join(\"final_model\")\n        self.timestamp: str = timestamp\n\nclass DataIngestionConfig:\n    def __init__(self, training_pipeline_config: TrainingPipelineConfig):\n        self.data_ingestion_dir: str = os.path.join(training_pipeline_config.artifact_dir, DATA_INGESTION_DIR_NAME)\n        self.feature_store_anime_file_path: str = os.path.join(self.data_ingestion_dir, DATA_INGESTION_FEATURE_STORE_DIR, ANIME_FILE_NAME) \n        self.feature_store_userrating_file_path: str = os.path.join(self.data_ingestion_dir, DATA_INGESTION_FEATURE_STORE_DIR, RATING_FILE_NAME)\n        self.anime_filepath: str = ANIME_FILE_PATH\n        self.rating_filepath: str = RATING_FILE_PATH \n\nclass DataTransformationConfig: \n    def __init__(self,training_pipeline_config:TrainingPipelineConfig): \n        self.data_transformation_dir:str = os.path.join(training_pipeline_config.artifact_dir,DATA_TRANSFORMATION_DIR)\n        self.merged_file_path:str = os.path.join(self.data_transformation_dir,DATA_TRANSFORMATION_TRANSFORMED_DATA_DIR,MERGED_FILE_NAME)\n\nclass CollaborativeModelConfig: \n    def __init__(self,training_pipeline_config:TrainingPipelineConfig): \n        self.model_trainer_dir:str = os.path.join(training_pipeline_config.artifact_dir,MODEL_TRAINER_DIR_NAME)\n        self.svd_trained_model_file_path:str = os.path.join(self.model_trainer_dir,MODEL_TRAINER_COL_TRAINED_MODEL_DIR,MODEL_TRAINER_SVD_TRAINED_MODEL_NAME)\n        self.user_knn_trained_model_file_path:str = os.path.join(self.model_trainer_dir,MODEL_TRAINER_COL_TRAINED_MODEL_DIR,MODEL_TRAINER_USER_KNN_TRAINED_MODEL_NAME)\n        self.item_knn_trained_model_file_path:str = os.path.join(self.model_trainer_dir,MODEL_TRAINER_COL_TRAINED_MODEL_DIR,MODEL_TRAINER_ITEM_KNN_TRAINED_MODEL_NAME)\n\nclass ContentBasedModelConfig: \n    def __init__(self,training_pipeline_config:TrainingPipelineConfig): \n        self.model_trainer_dir:str = os.path.join(training_pipeline_config.artifact_dir,MODEL_TRAINER_DIR_NAME)\n        self.cosine_similarity_model_file_path:str = os.path.join(self.model_trainer_dir,MODEL_TRAINER_CON_TRAINED_MODEL_DIR,MODEL_TRAINER_COSINESIMILARITY_MODEL_NAME)<\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-artifacts-entity\">Artifacts entity<\/h3>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/entity\/artifact_entity.py\" target=\"_blank\" rel=\"nofollow noopener\">entity\/artifact_entity.py<\/a> file defines classes for artifacts generated at various stages. These artifacts help track and manage intermediate outputs such as processed datasets and trained models.<\/p>\n<pre class=\"wp-block-code\"><code>@dataclass\nclass DataIngestionArtifact: \n    feature_store_anime_file_path:str\n    feature_store_userrating_file_path:str\n\n@dataclass\nclass DataTransformationArtifact:\n    merged_file_path:str\n\n@dataclass\nclass CollaborativeModelArtifact:\n    svd_file_path:str\n    item_based_knn_file_path:str\n    user_based_knn_file_path:str\n \n@dataclass\nclass ContentBasedModelArtifact:\n    cosine_similarity_model_file_path:str<\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-recommendation-system-model-training\">Recommendation System \u2013 Model Training<\/h2>\n<p>In this project, we implement three types of recommendation systems to enhance the anime recommendation experience:\u00a0\u00a0<\/p>\n<ol class=\"wp-block-list\">\n<li>Collaborative Recommendation System<\/li>\n<li>Content-Based Recommendation System<\/li>\n<li>Top Anime Recommendation System<\/li>\n<\/ol>\n<p>Each approach plays a unique role in delivering personalized recommendations. By breaking down each component, we will gain a deeper understanding.<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-1-collaborative-recommendation-system\">1. Collaborative Recommendation System<\/h2>\n<p>This Collaborative <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2022\/06\/recommender-systems-from-scratch\/\" target=\"_blank\" rel=\"noopener\">Recommendation System<\/a> suggests items to users based on the preferences and behaviours of other users. It operates under the assumption that if two users have shown similar interests in the past, they are likely to have similar preferences in the future. This approach is widely used in platforms like Netflix, Amazon, and anime <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/2018\/06\/comprehensive-guide-recommendation-engine-python\/\" target=\"_blank\" rel=\"noopener\">recommendation engines<\/a> to provide personalized suggestions.\u00a0In our case, we apply this recommendation technique to identify users with similar preferences and suggest anime based on their shared interests.<\/p>\n<p>We will follow the below workflow to build our recommendation system. Each step is carefully structured to ensure seamless integration, starting with data collection, followed by transformation, and finally training a model to generate meaningful recommendations.\u00a0<\/p>\n<figure class=\"wp-block-image size-full figure  mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"1064\" height=\"507\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_173153.webp\" alt=\"Collaborative Recommendation System\" class=\"wp-image-221572\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_173153.webp 1064w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_173153-300x143.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_173153-768x366.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_173153-150x71.webp 150w\" sizes=\"auto, (max-width: 1064px) 100vw, 1064px\"\/><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-a-data-ingestion\">A. Data Ingestion<\/h3>\n<p>Data ingestion is the process of collecting, importing, and transferring data from various sources into a data storage system or pipeline for further processing and analysis. It is a crucial first step in any data-driven application, as it enables the system to access and work with the raw data required to generate insights, train models, or perform other tasks.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-data-ingestion-component\">Data Ingestion Component<\/h4>\n<p>We define a DataIngestion class in <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/components\/data_ingestion.py\" target=\"_blank\" rel=\"nofollow noopener\">components\/data_ingestion.py<\/a> file which handles the process of fetching datasets from Hugging Face Datasets Hub, and loading them into Pandas DataFrames. It utilizes <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/entity\/config_entity.py\" target=\"_blank\" rel=\"nofollow noopener\">DataIngestionConfig<\/a>\u00a0to obtain the necessary file paths and configurations for the ingestion process. The ingest_data method loads the anime and user rating datasets, exports them as CSV files to the feature store, and returns a <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/entity\/artifact_entity.py\" target=\"_blank\" rel=\"nofollow noopener\">DataIngestionArtifact <\/a>containing the paths of the ingested files.\u00a0This class encapsulates the data ingestion logic, ensuring that data is properly fetched, stored, and made accessible for further stages of the pipeline.<\/p>\n<pre class=\"wp-block-code\"><code>class DataIngestion: \n    def __init__(self, data_ingestion_config: DataIngestionConfig): \n        self.data_ingestion_config = data_ingestion_config \n\n    def fetch_data_from_huggingface(self, dataset_path: str, split: str = None) -&gt; pd.DataFrame: \n        dataset = load_dataset(dataset_path, split=split)\n        df = pd.DataFrame(dataset['train'])\n        return df  \n\n    def ingest_data(self) -&gt; DataIngestionArtifact: \n        anime_df = self.fetch_data_from_huggingface(self.data_ingestion_config.anime_filepath)\n        rating_df = self.fetch_data_from_huggingface(self.data_ingestion_config.rating_filepath)\n\n        export_data_to_dataframe(anime_df, file_path=self.data_ingestion_config.feature_store_anime_file_path)\n        export_data_to_dataframe(rating_df, file_path=self.data_ingestion_config.feature_store_userrating_file_path)\n\n        dataingestionartifact = DataIngestionArtifact(\n            feature_store_anime_file_path=self.data_ingestion_config.feature_store_anime_file_path,\n            feature_store_userrating_file_path=self.data_ingestion_config.feature_store_userrating_file_path\n        ) \n        return dataingestionartifact <\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-b-data-nbsp-transformation\">B. Data\u00a0Transformation<\/h3>\n<p>Data transformation is the process of converting raw data into a format or structure that is suitable for analysis, modelling, or integration into a system. It is a crucial step in the data preprocessing pipeline, especially for machine learning, as it helps ensure that the data is clean, consistent, and formatted in a way that models can effectively use.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-data-transformation-component\">Data Transformation Component<\/h4>\n<p>In <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/components\/data_transformation.py\" target=\"_blank\" rel=\"nofollow noopener\">components\/data_transformation.py<\/a> file, we implement the DataTransformation class to manage the transformation of raw data into a cleaned and merged dataset, ready for further processing. The class includes methods to read data from CSV files, merge two datasets (anime and ratings), clean and filter the merged data. Specifically, the merge_data method combines the datasets based on a common column (anime_id), while the clean_filter_data method handles tasks like replacing missing values, converting columns to numeric types, filtering rows based on conditions, and removing unnecessary columns. The initiate_data_transformation method coordinates the entire transformation process, storing the resulting transformed dataset in the specified location using\u00a0<a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/entity\/artifact_entity.py\" target=\"_blank\" rel=\"nofollow noopener\">DataTransformationArtifact<\/a>\u00a0entity.<\/p>\n<pre class=\"wp-block-code\"><code>class DataTransformation: \n    def __init__(self,data_ingestion_artifact:DataIngestionArtifact,data_transformation_config:DataTransformationConfig):\n        self.data_ingestion_artifact = data_ingestion_artifact\n        self.data_transformation_config = data_transformation_config \n    \n    @staticmethod\n    def read_data(file_path)-&gt;pd.DataFrame: \n        return pd.read_csv(file_path) \n    \n    @staticmethod\n    def merge_data(anime_df: pd.DataFrame, rating_df: pd.DataFrame) -&gt; pd.DataFrame: \n        merged_df = pd.merge(rating_df, anime_df, on=\"anime_id\", how=\"inner\") \n        return merged_df \n\n    @staticmethod\n    def clean_filter_data(merged_df: pd.DataFrame) -&gt; pd.DataFrame: \n        merged_df['average_rating'].replace('UNKNOWN', np.nan)\n        merged_df['average_rating'] = pd.to_numeric(merged_df['average_rating'], errors=\"coerce\")\n        merged_df['average_rating'].fillna(merged_df['average_rating'].median())\n        merged_df = merged_df[merged_df['average_rating'] &gt; 6]\n        cols_to_drop = [  'username', 'overview', 'type', 'episodes', 'producers', 'licensors', 'studios', 'source',   'rank', 'popularity', 'favorites', 'scored by', 'members' ]\n        cleaned_df = merged_df.copy()\n        cleaned_df.drop(columns=cols_to_drop, inplace=True) \n        return cleaned_df \n        \n    def initiate_data_transformation(self)-&gt;DataTransformationArtifact: \n        anime_df = DataTransformation.read_data(self.data_ingestion_artifact.feature_store_anime_file_path)\n        rating_df = DataTransformation.read_data(self.data_ingestion_artifact.feature_store_userrating_file_path) \n        merged_df = DataTransformation.merge_data(anime_df, rating_df)\n        transformed_df = DataTransformation.clean_filter_data(merged_df)\n        export_data_to_dataframe(transformed_df, self.data_transformation_config.merged_file_path)\n        data_transformation_artifact = DataTransformationArtifact( merged_file_path=self.data_transformation_config.merged_file_path) \n        return data_transformation_artifact <\/code><\/pre>\n<h3 class=\"wp-block-heading\" id=\"h-c-collaborative-recommender\">C. Collaborative Recommender<\/h3>\n<p>The Collaborative filtering is widely used in recommendation systems, where predictions are made based on user-item interactions rather than explicit features of the items.<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-collaborative-modelling\">Collaborative Modelling<\/h4>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/model_trainer\/collaborative_modelling.py\" target=\"_blank\" rel=\"nofollow noopener\">CollaborativeAnimeRecommender <\/a>class is designed to provide personalized anime recommendations using collaborative filtering techniques. It employs three different models:<\/p>\n<ol class=\"wp-block-list\">\n<li><b>Singular Value Decomposition (SVD)<\/b> :<b>\u2013<\/b> A matrix factorization technique that learns latent factors representing user preferences and anime characteristics, enabling personalized recommendations based on past ratings.<\/li>\n<li><b>Item-Based K-Nearest Neighbors (KNN) :\u2013<\/b> Finds similar anime titles based on user rating patterns, recommending shows similar to a given anime.<\/li>\n<li><b>User-Based K-Nearest Neighbors (KNN) :\u2013<\/b> Identifies users with similar preferences and suggests anime that like-minded users have enjoyed.<\/li>\n<\/ol>\n<p>The class processes raw user ratings, constructs interaction matrices, and trains the models to generate tailored recommendations. The recommender provides predictions for individual users, recommends similar anime titles, and suggests new shows based on user similarity. By leveraging collaborative filtering techniques, this system enhances user experience by offering personalized and relevant anime recommendations.<\/p>\n<pre class=\"wp-block-code\"><code>class CollaborativeAnimeRecommender: \n    def __init__(self, df): \n        self.df = df\n        self.svd = None\n        self.knn_item_based = None\n        self.knn_user_based = None\n        self.prepare_data() \n  \n    def prepare_data(self): \n        self.df = self.df.drop_duplicates()\n        reader = Reader(rating_scale=(1, 10))\n        self.data = Dataset.load_from_df(self.df[['user_id', 'anime_id', 'rating']], reader)\n        self.anime_pivot = self.df.pivot_table(index='name', columns=\"user_id\", values=\"rating\").fillna(0)\n        self.user_pivot = self.df.pivot_table(index='user_id', columns=\"name\", values=\"rating\").fillna(0)\n         \n    def train_svd(self): \n        self.svd = SVD()\n        cross_validate(self.svd, self.data, cv=5)\n        trainset = self.data.build_full_trainset()\n        self.svd.fit(trainset) \n \n    def train_knn_item_based(self): \n        item_user_matrix = csr_matrix(self.anime_pivot.values)\n        self.knn_item_based = NearestNeighbors(metric=\"cosine\", algorithm='brute')\n        self.knn_item_based.fit(item_user_matrix) \n        \n    def train_knn_user_based(self): \n        user_item_matrix = csr_matrix(self.user_pivot.values)\n        self.knn_user_based = NearestNeighbors(metric=\"cosine\", algorithm='brute')\n        self.knn_user_based.fit(user_item_matrix) \n \n    def print_unique_user_ids(self): \n        unique_user_ids = self.df['user_id'].unique() \n        return unique_user_ids \n    \n    def get_svd_recommendations(self, user_id, n=10, svd_model=None)-&gt; pd.DataFrame: \n        svd_model = svd_model or self.svd\n        if svd_model is None:\n            raise ValueError(\"SVD model is not provided or trained.\") \n        if user_id not in self.df['user_id'].unique():\n            return f\"User ID '{user_id}' not found in the dataset.\" \n        anime_ids = self.df['anime_id'].unique() \n        predictions = [(anime_id, svd_model.predict(user_id, anime_id).est) for anime_id in anime_ids]\n        predictions.sort(key=lambda x: x[1], reverse=True) \n        recommended_anime_ids = [pred[0] for pred in predictions[:n]] \n        recommended_anime = self.df[self.df['anime_id'].isin(recommended_anime_ids)].drop_duplicates(subset=\"anime_id\")  \n        recommended_anime = recommended_anime.head(n) \n        return pd.DataFrame({ 'Anime Name': recommended_anime['name'].values, 'Genres': recommended_anime['genres'].values, 'Image URL': recommended_anime['image url'].values, 'Rating': recommended_anime['average_rating'].values})\n \n    def get_item_based_recommendations(self, anime_name, n_recommendations=10, knn_item_model=None): \n        knn_item_based = knn_item_model or self.knn_item_based\n        if knn_item_based is None:\n            raise ValueError(\"Item-based KNN model is not provided or trained.\") \n        if anime_name not in self.anime_pivot.index:\n            return f\"Anime title '{anime_name}' not found in the dataset.\" \n        query_index = self.anime_pivot.index.get_loc(anime_name) \n        distances, indices = knn_item_based.kneighbors( self.anime_pivot.iloc[query_index, :].values.reshape(1, -1), n_neighbors=n_recommendations + 1  ) \n        recommendations = []\n        for i in range(1, len(distances.flatten())):  \n            anime_title = self.anime_pivot.index[indices.flatten()[i]]\n            distance = distances.flatten()[i]\n            recommendations.append((anime_title, distance)) \n        recommended_anime_titles = [rec[0] for rec in recommendations] \n        filtered_df = self.df[self.df['name'].isin(recommended_anime_titles)].drop_duplicates(subset=\"name\") \n        filtered_df = filtered_df.head(n_recommendations) \n        return pd.DataFrame({ 'Anime Name': filtered_df['name'].values, 'Image URL': filtered_df['image url'].values, 'Genres': filtered_df['genres'].values, 'Rating': filtered_df['average_rating'].values }) \n    \n    def get_user_based_recommendations(self, user_id, n_recommendations=10, knn_user_model=None)-&gt; pd.DataFrame: \n        knn_user_based = knn_user_model or self.knn_user_based\n        if knn_user_based is None:\n            raise ValueError(\"User-based KNN model is not provided or trained.\") \n        user_id = float(user_id) \n        if user_id not in self.user_pivot.index:\n            return f\"User ID '{user_id}' not found in the dataset.\" \n        user_idx = self.user_pivot.index.get_loc(user_id) \n        distances, indices = knn_user_based.kneighbors( self.user_pivot.iloc[user_idx, :].values.reshape(1, -1), n_neighbors=n_recommendations + 1 ) \n        user_rated_anime = set(self.user_pivot.columns[self.user_pivot.iloc[user_idx, :] &gt; 0]) \n        all_neighbor_ratings = []\n        for i in range(1, len(distances.flatten())): \n            neighbor_idx = indices.flatten()[i]\n            neighbor_rated_anime = self.user_pivot.iloc[neighbor_idx, :]\n            neighbor_ratings = neighbor_rated_anime[neighbor_rated_anime &gt; 0]\n            all_neighbor_ratings.extend(neighbor_ratings.index) \n        anime_counter = Counter(all_neighbor_ratings) \n        recommendations = [(anime, count) for anime, count in anime_counter.items() if anime not in user_rated_anime]\n        recommendations.sort(key=lambda x: x[1], reverse=True)    \n        recommended_anime_titles = [rec[0] for rec in recommendations[:n_recommendations]]\n        filtered_df = self.df[self.df['name'].isin(recommended_anime_titles)].drop_duplicates(subset=\"name\") \n        filtered_df = filtered_df.head(n_recommendations) \n        return pd.DataFrame({ 'Anime Name': filtered_df['name'].values, 'Image URL': filtered_df['image url'].values, 'Genres': filtered_df['genres'].values, 'Rating': filtered_df['average_rating'].values }) <\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-collaborative-nbsp-model-trainer-component\">Collaborative\u00a0Model Trainer Component<\/h4>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/components\/collaborative_recommender.py\" target=\"_blank\" rel=\"nofollow noopener\">CollaborativeModelTrainer<\/a>\u00a0automates the training, saving, and deployment of the models. It ensures that trained models are stored locally and also uploaded to Hugging Face, making them easily accessible for generating recommendations.<\/p>\n<pre class=\"wp-block-code\"><code>class CollaborativeModelTrainer: \n    def __init__(self, collaborative_model_trainer_config: CollaborativeModelConfig, data_transformation_artifact: DataTransformationArtifact):\n        self.collaborative_model_trainer_config = collaborative_model_trainer_config\n        self.data_transformation_artifact = data_transformation_artifact \n\n    def initiate_model_trainer(self) -&gt; CollaborativeModelArtifact: \n        df = load_csv_data(self.data_transformation_artifact.merged_file_path)\n        recommender = CollaborativeAnimeRecommender(df) \n        # Train and save SVD model \n        recommender.train_svd()\n        save_model(model=recommender.svd,file_path= self.collaborative_model_trainer_config.svd_trained_model_file_path)\n        upload_model_to_huggingface(\n            model_path=self.collaborative_model_trainer_config.svd_trained_model_file_path,\n            repo_id=MODELS_FILEPATH,\n            filename=MODEL_TRAINER_SVD_TRAINED_MODEL_NAME\n        ) \n        svd_model = load_object(self.collaborative_model_trainer_config.svd_trained_model_file_path) \n        svd_recommendations = recommender.get_svd_recommendations(user_id=436, n=10, svd_model=svd_model) \n\n        # Train and save Item-Based KNN model \n        recommender.train_knn_item_based()\n        save_model(model=recommender.knn_item_based, file_path=self.collaborative_model_trainer_config.item_knn_trained_model_file_path)\n        upload_model_to_huggingface(\n            model_path=self.collaborative_model_trainer_config.item_knn_trained_model_file_path,\n            repo_id=MODELS_FILEPATH,\n            filename=MODEL_TRAINER_ITEM_KNN_TRAINED_MODEL_NAME\n        ) \n        item_knn_model = load_object(self.collaborative_model_trainer_config.item_knn_trained_model_file_path)\n        item_based_recommendations = recommender.get_item_based_recommendations(\n            anime_name=\"One Piece\", n_recommendations=10, knn_item_model=item_knn_model\n        )  \n\n        # Train and save User-Based KNN model \n        recommender.train_knn_user_based()\n        save_model(model=recommender.knn_user_based,file_path= self.collaborative_model_trainer_config.user_knn_trained_model_file_path)\n        upload_model_to_huggingface(\n            model_path=self.collaborative_model_trainer_config.user_knn_trained_model_file_path,\n            repo_id=MODELS_FILEPATH,\n            filename=MODEL_TRAINER_USER_KNN_TRAINED_MODEL_NAME\n        ) \n        user_knn_model = load_object(self.collaborative_model_trainer_config.user_knn_trained_model_file_path)\n        user_based_recommendations = recommender.get_user_based_recommendations(\n            user_id=817, n_recommendations=10, knn_user_model=user_knn_model\n        ) \n        return CollaborativeModelArtifact(\n            svd_file_path=self.collaborative_model_trainer_config.svd_trained_model_file_path,\n            item_based_knn_file_path=self.collaborative_model_trainer_config.item_knn_trained_model_file_path,\n            user_based_knn_file_path=self.collaborative_model_trainer_config.user_knn_trained_model_file_path\n        ) <\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-2-content-based-recommendation-system\">2. Content-Based Recommendation System<\/h2>\n<p>This content-based recommendation system suggests items to users by analyzing the attributes of items such as genre, keywords, or descriptions to generate recommendations based on similarity.<\/p>\n<p>For example, in an anime recommendation system, if a user enjoys a particular anime, the model identifies similar anime based on attributes like genre, voice actors, or themes. Techniques such as TF-IDF (Term Frequency-Inverse Document Frequency), cosine similarity, and machine learning models help in ranking and suggesting relevant items.<\/p>\n<p>Unlike collaborative filtering, which depends on user interactions, content-based filtering is independent of other users\u2019 preferences, making it effective even in cases with fewer user interactions (cold start problem).<\/p>\n<figure class=\"wp-block-image size-full figure  mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"913\" height=\"452\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_193215.webp\" alt=\"Content-Based Recommendation System\" class=\"wp-image-221576\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_193215.webp 913w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_193215-300x149.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_193215-768x380.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_193215-150x74.webp 150w\" sizes=\"auto, (max-width: 913px) 100vw, 913px\"\/><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-a-data-ingestion-0\">A. Data Ingestion<\/h3>\n<p>We use the artifacts from the data ingestion component discussed earlier to train the content-based recommender.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-b-content-based-recommender\">B. Content-Based Recommender<\/h3>\n<p>The Content-Based recommender is responsible for training recommendation models that analyze item attributes to generate personalized suggestions. It processes data, extracts relevant features, and builds models that identify similarities between items based on their content.\u00a0\u00a0<\/p>\n<h4 class=\"wp-block-heading\" id=\"h-content-based-modelling\">Content-Based Modelling<\/h4>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/model_trainer\/content_based_modelling.py\" target=\"_blank\" rel=\"nofollow noopener\">ContentBasedRecommender <\/a>class leverages TF-IDF (Term Frequency-Inverse Document Frequency) and Cosine Similarity to suggest anime based on their genre similarities. The model first processes the dataset by removing missing values and converting textual genre information into numerical feature vectors using TF-IDF vectorization. It then computes the cosine similarity between anime titles to measure their content similarity. The trained model is saved and later used to provide personalized recommendations by retrieving the most similar anime based on a given title.<\/p>\n<pre class=\"wp-block-code\"><code>class ContentBasedRecommender: \n    def __init__(self, df): \n        self.df = df.dropna()  \n        self.indices = pd.Series(self.df.index, index=self.df['name']).drop_duplicates() \n        self.tfv = TfidfVectorizer( min_df=3, strip_accents=\"unicode\", analyzer=\"word\", token_pattern=r'\\w{1,}', ngram_range=(1, 3), stop_words=\"english\" )\n        self.tfv_matrix = self.tfv.fit_transform(self.df['genres']) \n        self.cosine_sim = cosine_similarity(self.tfv_matrix, self.tfv_matrix)   \n        \n    def save_model(self, model_path):  \n        os.makedirs(os.path.dirname(model_path), exist_ok=True)\n        with open(model_path, 'wb') as f:\n            joblib.dump((self.tfv, self.cosine_sim), f) \n    \n    def get_rec_cosine(self, title, model_path, n_recommendations=5):  \n        with open(model_path, 'rb') as f:\n            self.tfv, self.cosine_sim = joblib.load(f)  \n        if self.df is None: \n            raise ValueError(\"The DataFrame is not loaded, cannot make recommendations.\") \n        if title not in self.indices.index: \n            return f\"Anime title '{title}' not found in the dataset.\" \n        idx = self.indicesHow to Build an Anime Recommendation System?\n        cosinesim_scores = list(enumerate(self.cosine_sim[idx]))\n        cosinesim_scores = sorted(cosinesim_scores, key=lambda x: x[1], reverse=True)[1:n_recommendations + 1]\n        anime_indices = [i[0] for i in cosinesim_scores] \n        return pd.DataFrame({ 'Anime name': self.df['name'].iloc[anime_indices].values, 'Image URL': self.df['image url'].iloc[anime_indices].values, 'Genres': self.df['genres'].iloc[anime_indices].values, 'Rating': self.df['average_rating'].iloc[anime_indices].values }) <\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-content-based-model-trainer-component\">Content-Based Model Trainer Component<\/h4>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/components\/content_based_recommender.py\" target=\"_blank\" rel=\"nofollow noopener\">ContentBasedModelTrainer<\/a>\u00a0class is responsible for automating the training and deployment of a content-based recommendation model. It loads the processed anime dataset from the data ingestion artifact, initializes the ContentBasedRecommender, and trains it using TF-IDF vectorization and cosine similarity. The trained model is then saved and uploaded to Hugging Face.<\/p>\n<pre class=\"wp-block-code\"><code>class ContentBasedModelTrainer:   \n    def __init__(self, content_based_model_trainer_config: ContentBasedModelConfig, data_ingestion_artifact: DataIngestionArtifact):\n            self.content_based_model_trainer_config = content_based_model_trainer_config\n            self.data_ingestion_artifact = data_ingestion_artifact \n\n    def initiate_model_trainer(self) -&gt; ContentBasedModelArtifact: \n        df = load_csv_data(self.data_ingestion_artifact.feature_store_anime_file_path) \n        recommender = ContentBasedRecommender(df=df ) \n        recommender.save_model(model_path=self.content_based_model_trainer_config.cosine_similarity_model_file_path)\n        upload_model_to_huggingface(\n            model_path=self.content_based_model_trainer_config.cosine_similarity_model_file_path,\n            repo_id=MODELS_FILEPATH,\n            filename=MODEL_TRAINER_COSINESIMILARITY_MODEL_NAME\n        ) \n        cosine_recommendations = recommender.get_rec_cosine(title=\"One Piece\", model_path=self.content_based_model_trainer_config.cosine_similarity_model_file_path, n_recommendations=10) \n        content_model_trainer_artifact = ContentBasedModelArtifact( cosine_similarity_model_file_path=self.content_based_model_trainer_config.cosine_similarity_model_file_path )\n        return content_model_trainer_artifact<\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-3-top-anime-recommendation-system\">3. Top Anime Recommendation System<\/h2>\n<p>It is common for newcomers to anime to seek out the most popular titles first. This top anime recommendation system is designed to help those new to the anime world easily discover popular, highly rated, and top-ranked anime all in one place by using simple sorting and filtering.\u00a0\u00a0<\/p>\n<figure class=\"wp-block-image size-full figure  mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"735\" height=\"470\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_195018.webp\" alt=\"Top Anime Recommendation System\" class=\"wp-image-221578\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_195018.webp 735w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_195018-300x192.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-08_195018-150x96.webp 150w\" sizes=\"auto, (max-width: 735px) 100vw, 735px\"\/><\/figure>\n<h3 class=\"wp-block-heading\" id=\"h-a-data-ingestion-1\">A. Data Ingestion<\/h3>\n<p>We utilize the artifacts from the previously discussed data ingestion component in this recommendation system.<\/p>\n<h3 class=\"wp-block-heading\" id=\"h-b-top-anime-recommender-component\">B. Top Anime Recommender Component<\/h3>\n<h4 class=\"wp-block-heading\" id=\"h-top-anime-filtering\">Top anime filtering<\/h4>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/model_trainer\/top_anime_filtering.py\" target=\"_blank\" rel=\"nofollow noopener\">PopularityBasedFiltering<\/a>\u00a0class is responsible for ranking and sorting anime using predefined popularity-based parameters. It analyzes the dataset by evaluating attributes such as rating, number of favorites, community size, and ranking position. The class includes specialized functions to extract top-performing anime within each category, ensuring a structured approach to filtering. Additionally, it manages missing data and refines the output for readability. By providing data-driven insights, this class plays a crucial role in identifying popular and highly-rated anime for recommendation purposes.<\/p>\n<pre class=\"wp-block-code\"><code>class PopularityBasedFiltering: \n    def __init__(self, df):  \n        self.df = df\n        self.df['average_rating'] = pd.to_numeric(self.df['average_rating'], errors=\"coerce\")\n        self.df['average_rating'].fillna(self.df['average_rating'].median()) \n         \n    def popular_animes(self, n=10): \n        sorted_df = self.df.sort_values(by=['popularity'], ascending=True)\n        top_n_anime = sorted_df.head(n)\n        return self._format_output(top_n_anime)\n    \n    def top_ranked_animes(self, n=10): \n        self.df['rank'] = self.df['rank'].replace('UNKNOWN', np.nan).astype(float)\n        df_filtered = self.df[self.df['rank'] &gt; 1]\n        sorted_df = df_filtered.sort_values(by=['rank'], ascending=True)\n        top_n_anime = sorted_df.head(n)\n        return self._format_output(top_n_anime)\n    \n    def overall_top_rated_animes(self, n=10): \n        sorted_df = self.df.sort_values(by=['average_rating'], ascending=False)\n        top_n_anime = sorted_df.head(n)\n        return self._format_output(top_n_anime)\n    \n    def favorite_animes(self, n=10): \n        sorted_df = self.df.sort_values(by=['favorites'], ascending=False)\n        top_n_anime = sorted_df.head(n)\n        return self._format_output(top_n_anime)\n    \n    def top_animes_members(self, n=10): \n        sorted_df = self.df.sort_values(by=['members'], ascending=False)\n        top_n_anime = sorted_df.head(n)\n        return self._format_output(top_n_anime)\n    \n    def popular_anime_among_members(self, n=10): \n        sorted_df = self.df.sort_values(by=['members', 'average_rating'], ascending=[False, False]).drop_duplicates(subset=\"name\") \n        popular_animes = sorted_df.head(n)\n        return self._format_output(popular_animes)\n    \n    def top_avg_rated(self, n=10):  \n        self.df['average_rating'] = pd.to_numeric(self.df['average_rating'], errors=\"coerce\")\n        median_rating = self.df['average_rating'].median()\n        self.df['average_rating'].fillna(median_rating)\n        top_animes = ( self.df.drop_duplicates(subset=\"name\").nlargest(n, 'average_rating')[['name', 'average_rating', 'image url', 'genres']] )\n        return self._format_output(top_animes)\n    \n    def _format_output(self, anime_df): \n        return pd.DataFrame({ 'Anime name': anime_df['name'].values, 'Image URL': anime_df['image url'].values, 'Genres': anime_df['genres'].values, 'Rating': anime_df['average_rating'].values })<\/code><\/pre>\n<h4 class=\"wp-block-heading\" id=\"h-top-anime-recommenders\">Top anime recommenders<\/h4>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/anime_recommender\/components\/top_anime_recommenders.py\" target=\"_blank\" rel=\"nofollow noopener\">PopularityBasedRecommendor<\/a>\u00a0class is responsible for recommending anime based on different popularity metrics. It utilizes an anime dataset stored in feature_store_anime_file_path, which was a DataIngestionArtifact. The class integrates the PopularityBasedFiltering class to generate anime recommendations according to various filtering criteria, such as top-ranked anime, most popular choices, community favorites, and highest-rated shows. By selecting a specific filter_type, users can retrieve the best match based on their preferred criteria.<\/p>\n<pre class=\"wp-block-code\"><code>class PopularityBasedRecommendor: \n    def __init__(self,data_ingestion_artifact = DataIngestionArtifact): \n        self.data_ingestion_artifact = data_ingestion_artifact \n        \n    def initiate_model_trainer(self,filter_type:str): \n        df = load_csv_data(self.data_ingestion_artifact.feature_store_anime_file_path) \n        recommender = PopularityBasedFiltering(df) \n        if filter_type == 'popular_animes': \n            popular_animes = recommender.popular_animes(n =10)  \n        elif filter_type == 'top_ranked_animes': \n            top_ranked_animes = recommender.top_ranked_animes(n =10)  \n        elif filter_type == 'overall_top_rated_animes': \n            overall_top_rated_animes = recommender.overall_top_rated_animes(n =10)  \n        elif filter_type == 'favorite_animes': \n            favorite_animes = recommender.favorite_animes(n =10)  \n        elif filter_type == 'top_animes_members': \n            top_animes_members = recommender.top_animes_members(n = 10)  \n        elif filter_type == 'popular_anime_among_members': \n            popular_anime_among_members = recommender.popular_anime_among_members(n =10) \n        elif filter_type == 'top_avg_rated': \n            top_avg_rated = recommender.top_avg_rated(n =10) <\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-training-pipeline\">Training Pipeline<\/h2>\n<figure class=\"wp-block-image size-full figure  mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"1010\" height=\"516\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_185707.webp\" alt=\"Training Pipeline\" class=\"wp-image-221579\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_185707.webp 1010w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_185707-300x153.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_185707-768x392.webp 768w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_185707-150x77.webp 150w\" sizes=\"auto, (max-width: 1010px) 100vw, 1010px\"\/><\/figure>\n<p>This Machine Learning Training Pipeline is designed to automate and streamline the process of building recommender models efficiently. The pipeline follows a structured workflow, beginning with data ingestion from Hugging face, followed by data transformation to preprocess and prepare the data for model training. It incorporates different modelling techniques, such as collaborative filtering, content-based approaches and Popularity-based filtering, ensuring optimal performance. The final trained models are stored in a Model Hub, enabling seamless deployment and continuous refinement. This structured approach ensures scalability, efficiency, and reproducibility in machine learning workflows.<\/p>\n<pre class=\"wp-block-code\"><code>class TrainingPipeline: \n    def __init__(self): \n        self.training_pipeline_config = TrainingPipelineConfig()\n\n    def start_data_ingestion(self) -&gt; DataIngestionArtifact: \n        data_ingestion_config = DataIngestionConfig(self.training_pipeline_config)\n        data_ingestion = DataIngestion(data_ingestion_config=data_ingestion_config)\n        data_ingestion_artifact = data_ingestion.ingest_data() \n        return data_ingestion_artifact \n\n    def start_data_transformation(self, data_ingestion_artifact: DataIngestionArtifact) -&gt; DataTransformationArtifact: \n        data_transformation_config = DataTransformationConfig(self.training_pipeline_config)\n        data_transformation = DataTransformation(\n            data_ingestion_artifact=data_ingestion_artifact,\n            data_transformation_config=data_transformation_config\n        )\n        data_transformation_artifact = data_transformation.initiate_data_transformation() \n        return data_transformation_artifact \n\n    def start_collaborative_model_training(self, data_transformation_artifact: DataTransformationArtifact) -&gt; CollaborativeModelArtifact: \n        collaborative_model_config = CollaborativeModelConfig(self.training_pipeline_config)\n        collaborative_model_trainer = CollaborativeModelTrainer(\n            collaborative_model_trainer_config=collaborative_model_config,\n            data_transformation_artifact=data_transformation_artifact )\n        collaborative_model_trainer_artifact = collaborative_model_trainer.initiate_model_trainer() \n        return collaborative_model_trainer_artifact \n\n    def start_content_based_model_training(self, data_ingestion_artifact: DataIngestionArtifact) -&gt; ContentBasedModelArtifact: \n        content_based_model_config = ContentBasedModelConfig(self.training_pipeline_config)\n        content_based_model_trainer = ContentBasedModelTrainer(\n            content_based_model_trainer_config=content_based_model_config,\n            data_ingestion_artifact=data_ingestion_artifact )\n        content_based_model_trainer_artifact = content_based_model_trainer.initiate_model_trainer() \n        return content_based_model_trainer_artifact \n\n    def start_popularity_based_filtering(self, data_ingestion_artifact: DataIngestionArtifact): \n        filtering = PopularityBasedRecommendor(data_ingestion_artifact=data_ingestion_artifact)\n        recommendations = filtering.initiate_model_trainer(filter_type=\"popular_animes\") \n        return recommendations \n\n    def run_pipeline(self): \n        # Data Ingestion\n        data_ingestion_artifact = self.start_data_ingestion() \n        # Content-Based Model Training\n        content_based_model_trainer_artifact = self.start_content_based_model_training(data_ingestion_artifact) \n        # Popularity-Based Filtering\n        popularity_recommendations = self.start_popularity_based_filtering(data_ingestion_artifact)  \n        # Data Transformation\n        data_transformation_artifact = self.start_data_transformation(data_ingestion_artifact) \n        # Collaborative Model Training\n        collaborative_model_trainer_artifact = self.start_collaborative_model_training(data_transformation_artifact)<\/code><\/pre>\n<p>Now that we\u2019ve completed creating the pipeline, run the training_pipeline.py file using the below code to view the artifacts generated in the previous steps.<\/p>\n<pre class=\"wp-block-code\"><code>python training_pipeline.py <\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-streamlit-app\">Streamlit App<\/h2>\n<p>The recommendation\u00a0<a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/app.py\" target=\"_blank\" rel=\"nofollow noopener\">application<\/a> is built using Streamlit, a lightweight and interactive framework for creating data-driven web apps. It is deployed on Hugging Face Spaces, allowing users to explore and interact with the anime recommendation system seamlessly. This setup provides an intuitive UI for discovering anime recommendations in real time.\u00a0Each time you push new changes, Hugging Face will redeploy your app automatically.<\/p>\n<figure class=\"wp-block-image size-full figure  mt-2 mb-2 d-table mx-auto\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"287\" src=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-11_132016-thumbnail_webp-600x300-1.webp\" alt=\"streamlit\" class=\"wp-image-221581\" srcset=\"https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-11_132016-thumbnail_webp-600x300-1.webp 600w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-11_132016-thumbnail_webp-600x300-1-300x144.webp 300w, https:\/\/cdn.analyticsvidhya.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-11_132016-thumbnail_webp-600x300-1-150x72.webp 150w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\"\/><\/figure>\n<h2 class=\"wp-block-heading\" id=\"h-docker-integration-for-deployment\">Docker Integration for Deployment<\/h2>\n<p>The <a href=\"https:\/\/huggingface.co\/spaces\/krishnaveni76\/Anime-Recommendation-System\/blob\/main\/Dockerfile\" target=\"_blank\" rel=\"nofollow noopener\">Dockerfile<\/a>\u00a0sets up a lightweight Python environment using the official Python 3.10 slim-buster image. It configures the working directory, copies application files, and installs dependencies from requirements.txt. Finally, it exposes port 8501 and runs the Streamlit app, making it accessible within the containerized environment.<\/p>\n<pre class=\"wp-block-code\"><code># Use the official Python image as a base\nFROM python:3.10-slim-buster\n\n# Set the working directory in the container\nWORKDIR \/app\n\n# Copy the app files into the container\nCOPY . .\n\n# Install required packages\nRUN pip install -r requirements.txt\n\n# Expose the port that Streamlit uses\nEXPOSE 8501\n\n# Run the Streamlit app\nCMD [\"streamlit\", \"run\", \"app.py\", \"--server.port=8501\", \"--server.address=0.0.0.0\"] <\/code><\/pre>\n<h2 class=\"wp-block-heading\" id=\"h-key-takeaways\">Key Takeaways<\/h2>\n<ul class=\"wp-block-list\">\n<li>We have designed an efficient, end-to-end pipeline that ensures smooth data flow from ingestion to recommendation, making the system scalable, robust, and production-ready.<\/li>\n<li>New users receive trending anime suggestions via a popularity-based engine, while returning users get hyper-personalized picks through collaborative filtering models.<\/li>\n<li>By deploying on Hugging Face Spaces with model versioning, you achieve cost-free productionization without paying any AWS\/GCP bills while maintaining scalability!<\/li>\n<li>The system leverages Docker for containerization, ensuring consistent environments across different deployments.<\/li>\n<li>Built using Streamlit, the app provides a clean, dynamic, and engaging user experience, making anime discovery fun and intuitive.<\/li>\n<\/ul>\n<p><strong>The media shown in this article is not owned by Analytics Vidhya and is used at the Author\u2019s discretion.<\/strong><a href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/karthik3852845\/\"\/><\/p>\n<h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2>\n<p>Congratulations! You have completed building the Recommendation app in no time. From acquiring data and preprocessing it to model training and deployment, this project highlights the power of getting things out there into the world! But hold up\u2026 we\u2019re not done yet! \ud83d\udca5 There\u2019s a whole lot more fun to come! You\u2019re now ready to build on something even cooler, like a Movie Recommendation app!\u00a0 \u00a0 \u00a0<\/p>\n<p>This is just the beginning of our adventure together, so buckle up\u2014there are many more exciting projects ahead! Let\u2019s keep learning and building!\u00a0<\/p>\n<h2 class=\"wp-block-heading\" id=\"h-frequently-asked-questions\">Frequently Asked Questions<\/h2>\n<div class=\"schema-faq wp-block-yoast-faq-block\">\n<div class=\"schema-faq-section\" id=\"faq-question-1739527279396\"><strong class=\"schema-faq-question\">Q1.\u00a0Can I tweak this for K-dramas or Hollywood movies?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">Ans. Absolutely! Swap the dataset, adjust genre weights in constants.py, and voil\u00e0 \u2013 you\u2019ve got a Squid Game or Marvel Recommender in no time!<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1739527320081\"><strong class=\"schema-faq-question\">Q2. Can I add a \u201cSurprise Me\u201d button for random anime picks?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">Ans. Yes! A \u201cSurprise Me\u201d button can be easily added using random.choice(), helping users discover hidden anime gems randomly!<\/p>\n<\/p><\/div>\n<div class=\"schema-faq-section\" id=\"faq-question-1739527355310\"><strong class=\"schema-faq-question\">Q3. Will Hugging Face charge me when my app goes viral?<\/strong> <\/p>\n<p class=\"schema-faq-answer\">Ans. Their free tier handles ~10K monthly visits. If you hit\u00a0Demon Slayer\u00a0levels of popularity, upgrade to PRO ($9\/month) for priority servers.<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<div class=\"border-top py-3 author-info my-4\">\n<div class=\"author-card d-flex align-items-center\">\n<div class=\"flex-shrink-0 overflow-hidden\">\n                                    <a href=\"https:\/\/www.analyticsvidhya.com\/blog\/author\/krishnaveni140696\/\" class=\"text-decoration-none active-avatar\"><br \/>\n                                                                       <img decoding=\"async\" src=\"https:\/\/av-eks-lekhak.s3.amazonaws.com\/media\/lekhak-profile-images\/converted_image_wE6UHKH.webp\" width=\"48\" height=\"48\" alt=\"Krishnaveni Ponna\" loading=\"lazy\" class=\"rounded-circle\"\/><\/p>\n<p>                                <\/a>\n                                <\/div>\n<\/p><\/div>\n<p>Hello! I&#8217;m a passionate AI and Machine Learning enthusiast currently exploring the exciting realms of Deep Learning, MLOps, and Generative AI. I enjoy diving into new projects and uncovering innovative techniques that push the boundaries of technology. I&#8217;ll be sharing guides, tutorials, and project insights based on my own experiences, so we can learn and grow together. Join me on this journey as we explore, experiment, and build amazing solutions in the world of AI and beyond!<\/p>\n<\/p><\/div>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>A few years ago, I fell into the world of anime from which I\u2019d never escape. As my watchlist was growing thinner and thinner, finding the next best anime became harder and harder. There are so many hidden gems out there, but how do I discover them? That\u2019s when I thought\u2014why not let Machine Learning [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":89621,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[3271,5815,5293,8103,2345],"dealstore":[],"offerexpiration":[],"class_list":["post-89620","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-anime","tag-blogathon","tag-build","tag-recommendation","tag-system"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Build an Anime Recommendation System? - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=89620\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Build an Anime Recommendation System? - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"A few years ago, I fell into the world of anime from which I\u2019d never escape. As my watchlist was growing thinner and thinner, finding the next best anime became harder and harder. There are so many hidden gems out there, but how do I discover them? That\u2019s when I thought\u2014why not let Machine Learning [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=89620\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-02-15T11:55:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1346\" \/>\n\t<meta property=\"og:image:height\" content=\"777\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"32 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=89620#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=89620\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"How to Build an Anime Recommendation System?\",\"datePublished\":\"2025-02-15T11:55:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=89620\"},\"wordCount\":2572,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=89620#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp\",\"keywords\":[\"Anime\",\"Blogathon\",\"Build\",\"RECOMMENDATION\",\"SYSTEM\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=89620#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=89620\",\"url\":\"https:\/\/fivemor.com\/?p=89620\",\"name\":\"How to Build an Anime Recommendation System? - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=89620#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=89620#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp\",\"datePublished\":\"2025-02-15T11:55:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=89620#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=89620\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=89620#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp\",\"width\":1346,\"height\":777},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=89620#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Build an Anime Recommendation System?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Build an Anime Recommendation System? - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=89620","og_locale":"en_US","og_type":"article","og_title":"How to Build an Anime Recommendation System? - Som2ny Network","og_description":"A few years ago, I fell into the world of anime from which I\u2019d never escape. As my watchlist was growing thinner and thinner, finding the next best anime became harder and harder. There are so many hidden gems out there, but how do I discover them? That\u2019s when I thought\u2014why not let Machine Learning [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=89620","og_site_name":"Som2ny Network","article_published_time":"2025-02-15T11:55:17+00:00","og_image":[{"width":1346,"height":777,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp","type":"image\/webp"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"32 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=89620#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=89620"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"How to Build an Anime Recommendation System?","datePublished":"2025-02-15T11:55:17+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=89620"},"wordCount":2572,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=89620#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp","keywords":["Anime","Blogathon","Build","RECOMMENDATION","SYSTEM"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=89620#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=89620","url":"https:\/\/fivemor.com\/?p=89620","name":"How to Build an Anime Recommendation System? - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=89620#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=89620#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp","datePublished":"2025-02-15T11:55:17+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=89620#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=89620"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=89620#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/02\/Screenshot_2025-02-07_135539.webp.webp","width":1346,"height":777},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=89620#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"How to Build an Anime Recommendation System?"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/89620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89620"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/89620\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/89621"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89620"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=89620"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=89620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}