Re: MLLib: loading saved model

2014-12-04 Thread manish_k
Hi Sameer,

Your model recreation should be:

val model = new LinearRegressionModel(weights, intercept)

As you have already got weights for linear regression model using stochastic
gradient descent, you just have to use LinearRegressionModel to construct
new model. Other points to notice is that weights should be in vector format
so you have to convert weights to vector after reading from file and your
intercept will be 0.0 as you mentioned.

Regards,
Manish



--
View this message in context: 
http://apache-spark-user-list.1001560.n3.nabble.com/MLLib-loading-saved-model-tp20281p20354.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: user-unsubscr...@spark.apache.org
For additional commands, e-mail: user-h...@spark.apache.org



MLLib: loading saved model

2014-12-03 Thread Sameer Tilak
Hi All,I am using LinearRegressionWithSGD and then I save the model weights and 
intercept. File that contains weights have this format:
1.204550.13560.000456..
Intercept is 0 since I am using train not setting the intercept so it can be 
ignored for the moment. I would now like to initialize a new model object and 
using these saved weights from the above file. We are using CDH 5.1
Something along these lines:
val weights = sc.textFile(linear-weights);val model = new 
LinearRegressionWithSGD(weights);
then use is as:
val valuesAndPreds = testData.map { point =  val prediction = 
model.predict(point.features)  (point.label, prediction)}

Any pointers to how do I do that?