O'Reilly logo

Machine Learning with Spark - Second Edition by Nick Pentreath, Manpreet Singh Ghotra, Rajdeep Dua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exploring the rating dataset

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required