Re: Extracting weights from linear regression model
Posted by
Theodore Vasiloudis on
URL: http://deprecated-apache-flink-user-mailing-list-archive.369.s1.nabble.com/Extracting-weights-from-linear-regression-model-tp3081p3084.html
Hello Trevor,
I assume you using the MultipleLinearRegression class in a manner similar to our examples, i.e.:
// Create multiple linear regression learner
val mlr = MultipleLinearRegression()
.setIterations(10)
.setStepsize(0.5)
.setConvergenceThreshold(0.001)
// Obtain training and testing data set
val trainingDS: DataSet[LabeledVector] = ...
val testingDS: DataSet[Vector] = ...
// Fit the linear model to the provided data
mlr.fit(trainingDS)
After you've run the fit method, you can get the weights by calling:
val WeightVector(weights, intercept) = mlr.weightsOption.get.collect().head
weights should be a flink.ml.math.DenseVector object and the intercept a Double.
Regards,
Theodore