1
我使用MLlib的LogisticRegressionWithLBFGS來訓練4個類的模型。MLlib LogisticRegressionWithLBFGS使用model.predict時出錯
這是準備我的數據的代碼,
val labeledTraining = trainingSetVectors.map{case(target,features) => LabeledPoint(target,features) }.cache()
val Array(trainingData, testData) = labeledTraining.randomSplit(Array(0.7, 0.3))
火車模型,
val model = new LogisticRegressionWithLBFGS()
model.setNumClasses(5)
model.run(trainingData)
當我嘗試測試模型我得到一個錯誤
val labelAndPreds = testData.map { Labeledpoint =>
val prediction = model.predict(LabeledPoint.features)
(LabeledPoint.target, prediction)
}
error: value predict is not a member of org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
爲什麼這是否發生?模型訓練沒有任何錯誤。
因爲它沒有。你訓練並立即丟棄模型。你稱之爲模型只是一個算法描述。 – zero323