July 2017
Beginner to intermediate
442 pages
10h 8m
English
We have finished content-based filtering and, from the following section onward, we will be discussing collaborative filtering using the ALS method:
# Collaborative filtering >>> import os """ First change the following directory link to where all input files do exist """ >>> os.chdir("D:\\Book writing\\Codes\\Chapter 7\\ml-latest-small\\ml-latest-small") >>> import pandas as pd >>> import numpy as np >>> import matplotlib.pyplot as plt >>> ratings = pd.read_csv("ratings.csv") >>> print (ratings.head()) >>> movies = pd.read_csv("movies.csv") >>> print (movies.head()) >>> rp = ratings.pivot_table(columns = ['movieId'],index = ['userId'],values = 'rating') >>> rp = rp.fillna(0) >>> A = rp.values >>> print ...Read now
Unlock full access