Database Reference
In-Depth Information
Finally, we will use foreachRDD to compute the MSE and RMSE metrics for each
model and print them to the console:
// print out the MSE and RMSE metrics for each model
per batch
predsAndTrue.foreachRDD { (rdd, time) =>
val mse1 = rdd.map { case (err1, err2) => err1 * err1
}.mean()
val rmse1 = math.sqrt(mse1)
val mse2 = rdd.map { case (err1, err2) => err2 * err2
}.mean()
val rmse2 = math.sqrt(mse2)
println(
s"""
|-------------------------------------------
|Time: $time
|-------------------------------------------
""".stripMargin)
println(s"MSE current batch: Model 1: $mse1; Model 2:
$mse2")
println(s"RMSE current batch: Model 1: $rmse1; Model
2: $rmse2")
println("...\n")
}
ssc.start()
ssc.awaitTermination()
}
}
If you terminated the producer earlier, start it again by executing sbt run and selecting
StreamingModelProducer . Once the producer is running again, in your second ter-
minal window, execute sbt run and choose the main class for MonitoringStream-
ingModel .
You should see the streaming program startup, and after about 10 seconds, the first batch
will be processed, printing output similar to the following:
Search WWH ::




Custom Search