Github user facaiy commented on a diff in the pull request:
https://github.com/apache/spark/pull/18554#discussion_r126863072
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/classification/OneVsRest.scala ---
@@ -317,7 +318,12 @@ final class OneVsRest @Since("1.4.0") (
val numClasses =
MetadataUtils.getNumClasses(labelSchema).fold(computeNumClasses())(identity)
instr.logNumClasses(numClasses)
- val multiclassLabeled = dataset.select($(labelCol), $(featuresCol))
+ val multiclassLabeled = getClassifier match {
+ // SPARK-21306: cache weightCol if necessary
+ case c: HasWeightCol if c.isDefined(c.weightCol) &&
c.getWeightCol.nonEmpty =>
+ dataset.select($(labelCol), $(featuresCol), c.getWeightCol)
+ case _ => dataset.select($(labelCol), $(featuresCol))
+ }
--- End diff --
Hi, @yanboliang . As @MLnick said, no all classifiers inherits
HasWeightCol, so it might cause confusion.
In my opinion, `setWeightCol` is an attribute owned by one specific
classifier, like `setProbabilityCol` and `setRawPredictionCol` for Logistic
Regreesion. So I'd suggest that user should configure the classifier itself,
rather than OneVsRest. Is it OK?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]