June 2017
Beginner to intermediate
296 pages
7h 4m
English
Believe it or not, the following code is all you need to replicate what was done with the Netflix prize and actually create what should be really good movie recommendations. However, as we'll see, your mileage may vary.:
data = sc.textFile("file:///SparkCourse/ml-100k/u.data") ratings = data.map(lambda l: l.split()).map(lambda l: Rating(int(l[0]), int(l[1]), float(l[2]))).cache()rank = 10numIterations = 20model = ALS.train(ratings, rank, numIterations)recommendations = model.recommendProducts(userID, 10)
Let's walk through it. All it's doing is opening up a text file from your hard drive, the same old u.data file you're used to all the time:
data = sc.textFile("file:///SparkCourse/ml-100k/u.data")
Next, it's ...
Read now
Unlock full access