From 2f30cdebb18488a4ba83dd06aa5c5c7126dd8a8c Mon Sep 17 00:00:00 2001 From: Sean Owen Date: Sat, 6 Mar 2021 07:32:01 -0800 Subject: [PATCH] [SPARK-34642][DOCS][ML] Fix TypeError in Pyspark Linear Regression docs ### What changes were proposed in this pull request? Fix a call to setParams in the Linear Regression docs example in Pyspark to avoid a TypeError. ### Why are the changes needed? The example is slightly wrong and we should not show an error in the docs. ### Does this PR introduce _any_ user-facing change? None ### How was this patch tested? Existing tests Closes #31760 from srowen/SPARK-34642. Authored-by: Sean Owen Signed-off-by: Dongjoon Hyun --- python/pyspark/ml/regression.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/python/pyspark/ml/regression.py b/python/pyspark/ml/regression.py index 8ecb68458f..122322e9f3 100644 --- a/python/pyspark/ml/regression.py +++ b/python/pyspark/ml/regression.py @@ -180,10 +180,8 @@ class LinearRegression(_JavaRegressor, _LinearRegressionParams, JavaMLWritable, >>> test1 = spark.createDataFrame([(Vectors.sparse(1, [0], [1.0]),)], ["features"]) >>> abs(model.transform(test1).head().newPrediction - 1.0) < 0.001 True - >>> lr.setParams("vector") - Traceback (most recent call last): - ... - TypeError: Method setParams forces keyword arguments. + >>> lr.setParams(featuresCol="vector") + LinearRegression... >>> lr_path = temp_path + "/lr" >>> lr.save(lr_path) >>> lr2 = LinearRegression.load(lr_path)