April 2017
Intermediate to advanced
532 pages
12h 39m
English
Let's now take a look at the rating data:
The code is located under RatingData:
object RatingData { def main(args: Array[String]) { val customSchema = StructType(Array( StructField("user_id", IntegerType, true), StructField("movie_id", IntegerType, true), StructField("rating", IntegerType, true), StructField("timestamp", IntegerType, true))) val spConfig = (new SparkConf).setMaster("local"). setAppName("SparkApp") val spark = SparkSession.builder() .appName("SparkRatingData").config(spConfig) .getOrCreate() val rating_df = spark.read.format("com.databricks.spark.csv") .option("delimiter", "t").schema(customSchema) .load("../../data/ml-100k/u.data") rating_df.createOrReplaceTempView("df") val num_ratings ...Read now
Unlock full access