Github user yanboliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12066#discussion_r60752890
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/Classifier.scala ---
    @@ -115,7 +116,16 @@ abstract class ClassificationModel[FeaturesType, M <: 
ClassificationModel[Featur
             }
             predictUDF(col(getFeaturesCol))
           }
    -      outputData = outputData.withColumn(getPredictionCol, predUDF)
    +      // determine number of classes either from metadata if provided.
    +      val labelSchema = dataset.schema($(labelCol))
    +      // extract label metadata from label column if present, or create a 
nominal attribute
    +      // to output the number of labels
    +      val labelAttribute = Attribute.fromStructField(labelSchema) match {
    --- End diff --
    
    Reply to your concerns:
    1, The ```labelAttribute``` only be prepared when model transform. We can 
add supporting for model fitting, but I'm not sure someone required this 
function.
    2, I think the attribute name should ```label```. Its values are the labels 
set such as ```Yes, No```, although it's one of the attributes in prediction 
column metadata.
    3, we can not do it in ```PredictorParams.validateAndTransformSchema```, 
because we did not use the return value of ```validateAndTransformSchema``` as 
the output DataFrame schema (You can refer the code 
[here](https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/ml/classification/Classifier.scala#L96)).
 The output DataFrame and its schema are generated at 
```ClassificationModel.transform``` and ```PredictionModel.transform``` by 
"withColumn" directly.


---
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]

Reply via email to