You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by Trevor Grant <tr...@gmail.com> on 2015/10/07 22:52:34 UTC
Extracting weights from linear regression model
Sorry if this is a novice question, but I can't figure out how to extract
the weights vector from a multiple linear regression model. I can
fit/predict, but I can't get the weight vector.
Any advice would be appreciated (even snide go read the docs comments, so
long as they point me to applicable docs, because I've been struggling with
this all day).
Thanks!
tg
Trevor Grant
Data Scientist
https://github.com/rawkintrevo
http://stackexchange.com/users/3002022/rawkintrevo
*"Fortunate is he, who is able to know the causes of things." -Virgil*
Re: Extracting weights from linear regression model
Posted by Theodore Vasiloudis <th...@gmail.com>.
Hello Trevor,
I assume you using the MultipleLinearRegression class in a manner similar
to our examples, i.e.:
// Create multiple linear regression learnerval mlr =
MultipleLinearRegression().setIterations(10).setStepsize(0.5).setConvergenceThreshold(0.001)
// Obtain training and testing data setval trainingDS:
DataSet[LabeledVector] = ...val testingDS: DataSet[Vector] = ...
// Fit the linear model to the provided datamlr.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
On Wed, Oct 7, 2015 at 10:52 PM, Trevor Grant <tr...@gmail.com>
wrote:
> Sorry if this is a novice question, but I can't figure out how to extract
> the weights vector from a multiple linear regression model. I can
> fit/predict, but I can't get the weight vector.
>
> Any advice would be appreciated (even snide go read the docs comments, so
> long as they point me to applicable docs, because I've been struggling with
> this all day).
>
> Thanks!
> tg
>
>
> Trevor Grant
> Data Scientist
> https://github.com/rawkintrevo
> http://stackexchange.com/users/3002022/rawkintrevo
>
> *"Fortunate is he, who is able to know the causes of things." -Virgil*
>
>