In this section, we will develop a predictive analytics model for predicting slowness in traffic for each row of the data using an LR algorithm. First, we create an LR estimator as follows:
val lr = new LinearRegression()
.setFeaturesCol("features")
.setLabelCol("label")
Then we invoke the fit() method to perform the training on the training set as follows:
println("Building ML regression model")
val lrModel = lr.fit(trainingData)
Now we have the fitted model, which means it is now capable of making predictions. So, let's start evaluating the model on the training and validation sets and calculating the RMSE, MSE, MAE, R squared, and so on:
println("Evaluating the model on the test set and calculating the regression metrics")
// **********************************************************************
val trainPredictionsAndLabels...