From b0cafdb6ccff9add89dc31c45adf87c8fa906aac Mon Sep 17 00:00:00 2001 From: Nick Pentreath Date: Sat, 7 May 2016 10:57:40 +0200 Subject: [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 Closes #12892 from MLnick/als-examples-cleanup. --- examples/src/main/python/ml/als_example.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'examples/src/main/python/ml') 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$ -- cgit v1.2.3