Global Baseline Estimate - 12S21009

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

PRAKTIKUM 03

RECOMMENDER SYSTEM

Global Baseline Estimate

Oleh:
Mikhael Janugrah Pakpahan - 12S21009
S1 Sistem Informasi

FAKULTAS INFORMATIKA DAN TEKNIK ELEKTRO


INSTITUT TEKNOLOGI DEL
T.A 2024/2025
DAFTAR ISI
Step 1: Data Loading and Preprocessing

We first need to load the dataset, which contains user ratings for different movies. The dataset will have
users as rows and movies as columns, with ratings as values. Unrated movies arerepresented as `NaN`.

• We load the dataset using `pandas` and set the `user_id` column as the index.
• We check for duplicate user IDs to ensure data consistency.

Step 2: Calculating Baseline Prediction


A baseline prediction is an initial estimate of how a user might rate a movie based on the global mean
rating, the user’s average rating, and the movie’s average rating. This providesafoundation before
incorporating neighbors' ratings.
• Global mean: The average rating across all users and movies.
• User bias: The difference between the global mean and the user’s mean rating.
• Item bias: The difference between the global mean and the movie’s mean rating.
• The baseline prediction is the sum of the global mean, user bias, and item bias.

Step 3: Removing Mean Rating to Normalize Data

In collaborative filtering, it’s important to center the ratings by removing the mean. This
helpscompare users' ratings by eliminating individual biases

Normalization: Subtract the movie's mean rating from the user ratings. This helps in comparingusers’
ratings more fairly by removing biases
Step 4: Finding Similar Users (Neighbors)

Next, we find users who have similar tastes to the target user using cosine similarity. Cosinesimilarity
measures how similar two users’ rating patterns are.

• Cosine similarity: Measures how similar users are by looking at the angle between their rating
vectors.
• We calculate the cosine similarity between the target user and all other users and retrieve the
top`k` most similar users.

Step 5: Predicting a User’s Rating for a Movie

To predict how a user will rate a specific movie, we look at their neighbors’ ratings for that movie.
The prediction is adjusted based on how similar the neighbors are to the target user.
• For each of the neighbors, we adjust their rating for the movie by subtracting their
baseline rating and multiplying it by their similarity to the target user.
• The final prediction is the baseline rating for the user-movie pair, adjusted by the
weighted sum of the neighbors’ opinions.

Step 6: Generating Recommendations

To generate recommendations, we predict the ratings for all movies the user hasn’t seen yet and return
the top `n` movies with the highest predicted ratings.

• We loop through all movies the user hasn’t rated, predict their ratings, and return the
top`n`movies with the highest predicted ratings.

Example Output :
Implementing Item-Based Collaborative Filtering(IBCF)Step

1: Modify the Similarity Calculation (Item-Based)

In the original UBCF code, similarities between users were calculated. To implement IBCF,
youneed to calculate item-to-item similarities instead. This is done by transposing the data
matrixsothat the items become rows and users become columns. After transposing, you can
computecosine similarity between items.

Step 2: Find the Most Similar Items (Neighbors)

In UBCF, the function identifies the most similar users for a given target user. In IBCF, we needto
identify the most similar items for a given target item
Step 3: Adjust the Prediction Function

In UBCF, rating predictions are based on ratings from similar users. In IBCF, you need to adjust the
logic to predict ratings based on the ratings that the target user has given to similar items.

Step 4: Adjust the Recommendation Function

The final function in the UBCF system generates recommendations by predicting ratings for items a
user has not rated, based on user similarities. In IBCF, modify this to predict ratings for unrated items
based on item similarities.
Step 5: Test the IBCF Module

After implementing the above changes, you should test your IBCF module using sample data. Ensure
that the system generates reasonable item recommendations based on item similarities.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy