text_html_output_1.png
from surprise import Dataset,Reader,SVD

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

from surprise import Dataset, Reader, SVD
reader = Reader()
ratings = pd.read_csv('../input/the-movies-dataset/ratings_small.csv')

rows = ratings.userId.unique()
columns = ratings.movieId.unique()
columns
rows

myData = np.array([0.0 for i in range(671 * 9066)])
mydf = pd.DataFrame(myData.reshape(671, -1))

mydf.columns = columns
mydf.index = rows
mydf

for i in range(100004):
    mydf.loc[ratings.loc[i, 'userId'], ratings.loc[i, 'movieId']] = ratings.loc[i, 'rating']
mydf

mydf