shahidki31 opened a new pull request #26038: [SPARK-29235][ML][Pyspark]Support 
avgMetrics in read/write of CrossValidatorModel
URL: https://github.com/apache/spark/pull/26038
 
 
   ### What changes were proposed in this pull request?
    Currently pyspark doesn't write/read `avgMetrics` in `CrossValidatorModel`, 
whereas scala supports it.
   
   ### Why are the changes needed?
    Test step to reproduce it:
   
   ```
   dataset = spark.createDataFrame([(Vectors.dense([0.0]), 0.0),
        (Vectors.dense([0.4]), 1.0),
        (Vectors.dense([0.5]), 0.0),
         (Vectors.dense([0.6]), 1.0),
         (Vectors.dense([1.0]), 1.0)] * 10,
        ["features", "label"])
   lr = LogisticRegression()
   grid = ParamGridBuilder().addGrid(lr.maxIter, [0, 1]).build()
   evaluator = BinaryClassificationEvaluator()
   cv = CrossValidator(estimator=lr, estimatorParamMaps=grid, 
evaluator=evaluator,parallelism=2)
   cvModel = cv.fit(dataset)
   cvModel.write().save("/tmp/model")
   cvModel2 = CrossValidatorModel.read().load("/tmp/model")
   print(cvModel.avgMetrics) # prints non empty result as expected
   print(cvModel2.avgMetrics). # Bug: prints an empty result.
   ```
   
   ### Does this PR introduce any user-facing change?
   No
   
   ### How was this patch tested?
   Manually tested
   
   Before patch:
   ```
   >>> cvModel.write().save("/tmp/model_0")
   >>> cvModel2 = CrossValidatorModel.read().load("/tmp/model_0")
   >>> print(cvModel2.avgMetrics)
   []
   ```
   
   After patch:
   ```
   >>> cvModel2 = CrossValidatorModel.read().load("/tmp/model_2")
   >>> print(cvModel2.avgMetrics[0])
   0.5
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to