【发布时间】:2016-06-23 23:28:20
【问题描述】:
我正在使用LinearRegressionWithSGD,然后我保存模型权重并截取。
包含权重的文件具有以下格式:
1.20455
0.1356
0.000456
Intercept 为 0,因为我使用的是 train 而不是设置截距,因此暂时可以忽略它。我现在想初始化一个新的模型对象并使用上述文件中保存的这些权重。我们正在使用 CDH 5.1
类似的东西:
// Here is the code the load data and train the model on it.
val weights = sc.textFile("linear-weights");
val model = new LinearRegressionWithSGD(weights);
然后使用如下:
// Here is where I want to use the trained model to predict on new data.
val valuesAndPreds = testData.map { point =>
// Predicting on new data.
val prediction = model.predict(point.features)
(point.label, prediction)
}
任何关于我如何做到这一点的指针?
【问题讨论】:
标签: scala apache-spark apache-spark-mllib