Reputation: 410
I have a working linear regression model:
lrModel
org.apache.spark.ml.regression.LinearRegressionModel
and I have data in a dataframe:
data
org.apache.spark.sql.DataFrame = [label: double, features: vector]
How do I use the model to predict? in my case, I want to do something like:
lrModel.predict(data) // which doesn't work
then compare the expected value (label) to the predicted value
Upvotes: 3
Views: 490
Reputation: 18022
To predict you need to have a Dataframe
, and convert it using the transform method which is part of all ML Models. Note that all of them require DataFrame
s to have the same structure of your training data, hence a fetures
column.
Upvotes: 1