diff options
author | Nick Pentreath <nickp@za.ibm.com> | 2016-05-07 10:57:40 +0200 |
---|---|---|
committer | Nick Pentreath <nickp@za.ibm.com> | 2016-05-07 10:57:40 +0200 |
commit | b0cafdb6ccff9add89dc31c45adf87c8fa906aac (patch) | |
tree | 1ce9876b0c6237387283cee2ff021dfb6815e0c4 /examples/src/main/python/ml | |
parent | df89f1d43d4eaa1dd8a439a8e48bca16b67d5b48 (diff) | |
download | spark-b0cafdb6ccff9add89dc31c45adf87c8fa906aac.tar.gz spark-b0cafdb6ccff9add89dc31c45adf87c8fa906aac.tar.bz2 spark-b0cafdb6ccff9add89dc31c45adf87c8fa906aac.zip |
[MINOR][ML][PYSPARK] ALS example cleanup
Cleans up ALS examples by removing unnecessary casts to double for `rating` and `prediction` columns, since `RegressionEvaluator` now supports `Double` & `Float` input types.
## How was this patch tested?
Manual compile and run with `run-example ml.ALSExample` and `spark-submit examples/src/main/python/ml/als_example.py`.
Author: Nick Pentreath <nickp@za.ibm.com>
Closes #12892 from MLnick/als-examples-cleanup.
Diffstat (limited to 'examples/src/main/python/ml')
-rw-r--r-- | examples/src/main/python/ml/als_example.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/src/main/python/ml/als_example.py b/examples/src/main/python/ml/als_example.py index ff0829b0dd..1a979ff5b5 100644 --- a/examples/src/main/python/ml/als_example.py +++ b/examples/src/main/python/ml/als_example.py @@ -48,12 +48,9 @@ if __name__ == "__main__": model = als.fit(training) # Evaluate the model by computing the RMSE on the test data - rawPredictions = model.transform(test) - predictions = rawPredictions\ - .withColumn("rating", rawPredictions.rating.cast("double"))\ - .withColumn("prediction", rawPredictions.prediction.cast("double")) - evaluator =\ - RegressionEvaluator(metricName="rmse", labelCol="rating", predictionCol="prediction") + predictions = model.transform(test) + evaluator = RegressionEvaluator(metricName="rmse", labelCol="rating", + predictionCol="prediction") rmse = evaluator.evaluate(predictions) print("Root-mean-square error = " + str(rmse)) # $example off$ |