How to generate tuples of (original label, predicted label) on Spark with MLlib?

后端 未结 1 1350
青春惊慌失措
青春惊慌失措 2021-01-07 07:01

I am trying to make predictions with the model that I got back from MLlib on Spark. The goal is to generate tuples of (orinalLabelInData, predictedLabel). Then those tuples

1条回答
  •  伪装坚强ぢ
    2021-01-07 07:42

    Well, according to the official documentation you can simply zip predictions and labels like this:

    predictions = model.predict(parsedTrainData.map(lambda x: x.features))
    labelsAndPredictions = parsedTrainData.map(lambda x: x.label).zip(predictions)
    

    0 讨论(0)
提交回复
热议问题