# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import pandas as pd 
import numpy as np
import seaborn as sns

df = pd.read_csv('ratings.csv')

df.head()

movie_titles = pd.read_csv('movies.csv')

movie_titles.head()

df = pd.merge(df,movie_titles, on ='movieId')

df.head()

df.describe()

ratings = pd.DataFrame(df.groupby('title')['rating'].mean())
ratings.head()

ratings['n_rating']= pd.DataFrame(df.groupby('title')['rating'].count())
ratings['n_rating'].head()

import matplotlib.pyplot as plt
# %matplotlib inline
ratings['rating'].hist(bins = 10)

ratings['n_rating'].hist(bins = 50)

sns.jointplot(x=ratings['rating'], y=ratings['n_rating'], data=ratings)

movie_matrix = df.pivot_table(index='userId', columns = 'title', values = 'rating')
movie_matrix.head()

ratings.sort_values('n_rating', ascending = False).head(10)

AFO_rating = movie_matrix['Air Force One (1997)']

Contact_rating = movie_matrix['Contact (1997)']

similar_AFO = movie_matrix.corrwith(AFO_rating)

similar_AFO = similar_AFO.dropna()
similar_AFO.sort_values(ascending=False)

similar_Contact = movie_matrix.corrwith(Contact_rating)

similar_Contact.head(20)



StarcoderdataJupyterScriptsDedupFiltered