huaxingao commented on a change in pull request #27190:
[SPARK-30504][PYTHON][ML] Set weightCol in OneVsRest(Model) _to_java and
_from_java
URL: https://github.com/apache/spark/pull/27190#discussion_r366525164
##########
File path: python/pyspark/ml/classification.py
##########
@@ -2558,11 +2558,17 @@ def _from_java(cls, java_stage):
labelCol = java_stage.getLabelCol()
predictionCol = java_stage.getPredictionCol()
rawPredictionCol = java_stage.getRawPredictionCol()
+ weightCol = (
+ java_stage.getWeightCol() if
+ java_stage.isDefined(java_stage.getParam("weightCol"))
+ else None)
classifier = JavaParams._from_java(java_stage.getClassifier())
parallelism = java_stage.getParallelism()
py_stage = cls(featuresCol=featuresCol, labelCol=labelCol,
predictionCol=predictionCol,
- rawPredictionCol=rawPredictionCol,
classifier=classifier,
- parallelism=parallelism)
+ rawPredictionCol=rawPredictionCol,
+ classifier=classifier, parallelism=parallelism)
+ if weightCol:
+ py_stage.setWeightCol(weightCol)
Review comment:
I think you may want to use something similar to what you have in
OneVsRestModel:
```
if java_stage.isDefined(java_stage.getParam("weightCol"):
py_stage.setWeightCol(java_stage.getWeightCol())
```
Then you can remove line 2561-2564. The code is simpler this way.
----------------------------------------------------------------
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]