What are Recommender Systems? (original) (raw)

Last Updated : 27 Dec, 2025

Recommender Systems are tools that suggest items to users based on their behaviour, preferences or past interactions. They help users find relevant products, movies, songs or content without manually searching for them. They are widely used in platforms like YouTube, Amazon and Netflix.

Recommender-Systems_

Recommender Systems

Types of Recommender Systems

Let's see the various types:

**1. Content-Based Filtering: Content-based filtering recommends items similar to those a user liked earlier by analyzing item features and user preference profiles.

**2. Collaborative Filtering: Collaborative filtering identifies similarities in user behavior and recommends items based on patterns derived from many users.

**3. Hybrid Recommendation Systems: Hybrid systems combine collaborative and content-based methods to offer more accurate and robust recommendations.

**4. Knowledge-Based Recommendation Systems: Knowledge-based systems use explicit domain knowledge and user requirements rather than historical behavior to suggest items.

**5. Context-Aware Recommendation Systems: These systems use contextual information such as time, location, device or mood to personalize recommendations.

Working

Let's see how a recommender system works,

Implementation

Let's see how a recommendation system works with an example of movie recommender system,

The used dataset can be downloaded from here.

Step 1: Load and Inspect Dataset

We will load the dataset and inspect the dataset,

Python `

import pandas as pd import numpy as np from sklearn.metrics.pairwise import cosine_similarity DATA_PATH = "" ratings = pd.read_csv(DATA_PATH + "ratings.csv") movies = pd.read_csv(DATA_PATH + "movies.csv") print("Ratings sample:") print(ratings.head()) print("\nMovies sample:") print(movies.head())

`

**Output:

Screenshot-2025-12-08-111954

Output

Step 2: Build User–Item Rating Matrix

ratings_matrix = ratings.pivot_table( index="userId", columns="movieId", values="rating" ) ratings_matrix = ratings_matrix.fillna(0) print(ratings_matrix.head())

`

**Output:

Screenshot-2025-12-08-111924

Output

Step 3: Compute Item–Item Similarity

item_vectors = ratings_matrix.T item_similarity = cosine_similarity(item_vectors) item_similarity_df = pd.DataFrame( item_similarity, index=item_vectors.index, columns=item_vectors.index )

`

Step 4: Build the Recommendation Function

def get_item_based_recommendations(user_id, ratings_matrix, item_similarity_df, top_n=10): user_ratings = ratings_matrix.loc[user_id] rated_movies = user_ratings[user_ratings > 0].index if len(rated_movies) == 0: return None scores = pd.Series(0.0, index=ratings_matrix.columns) sim_sums = pd.Series(0.0, index=ratings_matrix.columns) for movie_id in rated_movies: sim_vector = item_similarity_df[movie_id] scores += sim_vector * user_ratings[movie_id] sim_sums += sim_vector.abs() predicted_scores = scores / sim_sums.replace(0, np.nan) predicted_scores[rated_movies] = np.nan return predicted_scores.sort_values(ascending=False).head(top_n)

`

Step 5: Display Recommendations with Movie Titles

def pretty_print_recommendations(user_id, top_n=10): top_recs = get_item_based_recommendations( user_id, ratings_matrix, item_similarity_df, top_n ) if top_recs is None: print("No recommendations available.") return movie_lookup = movies.set_index("movieId") rec_movies = movie_lookup.loc[top_recs.index] rec_movies["score"] = top_recs.values print(f"\nTop {top_n} Recommendations for User {user_id}:") for _, row in rec_movies.iterrows(): print( f"- {row['title']} | Genres: {row['genres']} | Score: {row['score']:.3f}") pretty_print_recommendations(user_id=1, top_n=10)

`

**Output:

Screenshot-2025-12-08-111910

Output

Deep Learning Models Used in Recommender Systems

Let's see the various types of deep learning models that are used in recommender systems,

1. Neural Collaborative Filtering (NCF)

2. Autoencoders

3. Recurrent Neural Networks (RNNs)

4. Convolutional Neural Networks (CNNs)

5. Transformer Models

6. Wide & Deep Models / DeepFM

Importance

Let's see the importance of recommender systems,