<jupyter_start><jupyter_text><jupyter_code># import pandas library
import pandas as pd
 
# Get the data
column_names = ['user_id', 'item_id', 'rating', 'timestamp']
 
path = 'file.tsv'
 
df = pd.read_csv(path, sep='\t', names=column_names)
 
# Check the head of the data
df.head()
# Check out all the movies and their respective IDs
movie_titles = pd.read_csv('Movie_Id_Titles.csv')
movie_titles.head()
data = pd.merge(df, movie_titles, on='item_id')
data.head()
# Calculate mean rating of all movies
data.groupby('title')['rating'].mean().sort_values(ascending=False).head()
# Calculate count rating of all movies
data.groupby('title')['rating'].count().sort_values(ascending=False).head()
# creating dataframe with 'rating' count values
ratings = pd.DataFrame(data.groupby('title')['rating'].mean())
 
ratings['num of ratings'] = pd.DataFrame(data.groupby('title')['rating'].count())
 
ratings.head()
import matplotlib.pyplot as plt
import seaborn as sns
 
sns.set_style('white')
%matplotlib inline
# plot graph of 'num of ratings column'
plt.figure(figsize =(10, 4))
 
ratings['num of ratings'].hist(bins = 70)
# plot graph of 'ratings' column
plt.figure(figsize =(10, 4))
 
ratings['rating'].hist(bins = 70)
# Sorting values according to
# the 'num of rating column'
moviemat = data.pivot_table(index ='user_id',
              columns ='title', values ='rating')
 
moviemat.head()
 
ratings.sort_values('num of ratings', ascending = False).head(10)
# analysing correlation with similar movies
starwars_user_ratings = moviemat['Star Wars (1977)']
liarliar_user_ratings = moviemat['Liar Liar (1997)']
 
starwars_user_ratings.head()
# analysing correlation with similar movies
similar_to_starwars = moviemat.corrwith(starwars_user_ratings)
similar_to_liarliar = moviemat.corrwith(liarliar_user_ratings)
 
corr_starwars = pd.DataFrame(similar_to_starwars, columns =['Correlation'])
corr_starwars.dropna(inplace = True)
 
corr_starwars.head()
# Similar movies like starwars
corr_starwars.sort_values('Correlation', ascending = False).head(10)
corr_starwars = corr_starwars.join(ratings['num of ratings'])
 
corr_starwars.head()
 
corr_starwars[corr_starwars['num of ratings']>100].sort_values('Correlation', ascending = False).head()
# Similar movies as of liarliar
corr_liarliar = pd.DataFrame(similar_to_liarliar, columns =['Correlation'])
corr_liarliar.dropna(inplace = True)
 
corr_liarliar = corr_liarliar.join(ratings['num of ratings'])
corr_liarliar[corr_liarliar['num of ratings']>100].sort_values('Correlation', ascending = False).head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13514563106796115, 'fraction_numerical': 0.01087378640776699, 'mean_word_length': 6.712574850299402, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '377777', 'license': 'MIT', 'n_tokens_mistral': 960, 'n_tokens_neox': 887, 'n_words': 197, 'path': 'Movie_Recommender_system.ipynb', 'repo_name': 'Pankhudi31/Movie-Recommender-System', 'size': '2575'}