April 2017
Intermediate to advanced
532 pages
12h 39m
English
In this example, we will use the same MovieLens dataset that we used in the previous chapter. Use the directory in which you placed the MovieLens 100k dataset as the input path in the following code.
First, let's inspect the raw ratings dataset:
object FeatureExtraction { def getFeatures(): Dataset[FeatureExtraction.Rating] = { val spark = SparkSession.builder.master("local[2]").appName("FeatureExtraction").getOrCreate() import spark.implicits._ val ratings = spark.read.textFile("/data/ml-100k 2/u.data").map(parseRating) println(ratings.first()) return ratings } case class Rating(userId: Int, movieId: Int, rating: Float) def parseRating(str: String): Rating = { val fields = str.split("t") ...Read now
Unlock full access