Predicting prices and evaluating the model

ShortTermPredictionServiceImpl is the class that actually performs the prediction with the given model and data. At first, it transforms PriceData into a Spark DataFrame with the scheme corresponding to the one used for training by calling transformPriceData(priceData: PriceData). Then, the model.transform(dataframe) method is called; we extract the variables we need, write into the debugger log and return to the caller:

override def predictPriceDeltaLabel(priceData: PriceData, mlModel: org.apache.spark.ml.Transformer): (String, Row) = {        val df = transformPriceData(priceData)        val prediction = mlModel.transform(df) val predictionData = prediction.select("probability", "prediction", "rawPrediction").head() ...

Get Scala Machine Learning Projects 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.