diff options
Diffstat (limited to 'examples/src/main/python/mllib/naive_bayes_example.py')
-rw-r--r-- | examples/src/main/python/mllib/naive_bayes_example.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/examples/src/main/python/mllib/naive_bayes_example.py b/examples/src/main/python/mllib/naive_bayes_example.py index 749353b20e..a29fcccac5 100644 --- a/examples/src/main/python/mllib/naive_bayes_example.py +++ b/examples/src/main/python/mllib/naive_bayes_example.py @@ -50,7 +50,7 @@ if __name__ == "__main__": # Make prediction and test accuracy. predictionAndLabel = test.map(lambda p: (model.predict(p.features), p.label)) - accuracy = 1.0 * predictionAndLabel.filter(lambda (x, v): x == v).count() / test.count() + accuracy = 1.0 * predictionAndLabel.filter(lambda pl: pl[0] == pl[1]).count() / test.count() print('model accuracy {}'.format(accuracy)) # Save and load model @@ -59,7 +59,7 @@ if __name__ == "__main__": model.save(sc, output_dir) sameModel = NaiveBayesModel.load(sc, output_dir) predictionAndLabel = test.map(lambda p: (sameModel.predict(p.features), p.label)) - accuracy = 1.0 * predictionAndLabel.filter(lambda (x, v): x == v).count() / test.count() + accuracy = 1.0 * predictionAndLabel.filter(lambda pl: pl[0] == pl[1]).count() / test.count() print('sameModel accuracy {}'.format(accuracy)) # $example off$ |