How to do it...

  1. Start a new project in IntelliJ or in an IDE of your choice. Make sure that the necessary JAR files are included.
  1. Set up the package location where the program will reside:
package spark.ml.cookbook.chapter13
  1. Import the necessary packages:
import java.time.LocalDateTimeimport scala.util.Random._
  1. Define a Scala case class to model click events by users that contains user identifier, IP address, time of event, URL, and HTTP status code:
case class ClickEvent(userId: String, ipAddress: String, time: String, url: String, statusCode: String)
  1. Define status codes for generation:
val statusCodeData = Seq(200, 404, 500)
  1. Define URLs for generation:
val urlData = Seq("http://www.fakefoo.com", "http://www.fakefoo.com/downloads" ...

Get Apache Spark 2.x Machine Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.