我正在使用LinearRegressionWithSGD
,然后我保存模型权重并截取。
包含权重的文件具有以下格式:
1.20455
0.1356
0.000456
截距为 0,因为我使用的是火车而不是设置截距,因此暂时可以忽略它。我现在想初始化一个新的模型对象并使用上述文件中保存的这些权重。我们正在使用 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)
}
任何指示我该怎么做?