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

    https://github.com/apache/spark/pull/14834#discussion_r78464438
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
 ---
    @@ -311,8 +350,28 @@ class LogisticRegression @Since("1.2.0") (
     
         val histogram = labelSummarizer.histogram
         val numInvalid = labelSummarizer.countInvalid
    -    val numClasses = histogram.length
         val numFeatures = summarizer.mean.size
    +    val numFeaturesPlusIntercept = if (getFitIntercept) numFeatures + 1 
else numFeatures
    +
    +    val numClasses = 
MetadataUtils.getNumClasses(dataset.schema($(labelCol))) match {
    +      case Some(n: Int) =>
    +        require(n >= histogram.length, s"Specified number of classes $n 
was " +
    +          s"less than the number of unique labels ${histogram.length}.")
    +        n
    +      case None => histogram.length
    +    }
    +
    +    val isBinaryClassification = numClasses == 1 || numClasses == 2
    +    val isMultinomial = $(family) match {
    +      case "binomial" =>
    +        require(isBinaryClassification, s"Binomial family only supports 1 
or 2 " +
    +        s"outcome classes but found $numClasses.")
    +        false
    +      case "multinomial" => true
    +      case "auto" => !isBinaryClassification
    +      case other => throw new IllegalArgumentException(s"Unsupported 
family: $other")
    +    }
    --- End diff --
    
    Done.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to