aboutsummaryrefslogtreecommitdiff
path: root/mllib/src/main/scala
diff options
context:
space:
mode:
Diffstat (limited to 'mllib/src/main/scala')
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
index 3e8040d3e9..ffd03e55b5 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
@@ -745,7 +745,7 @@ private[classification] class MultiClassSummarizer extends Serializable {
def countInvalid: Long = totalInvalidCnt
/** @return The number of distinct labels in the input dataset. */
- def numClasses: Int = distinctMap.keySet.max + 1
+ def numClasses: Int = if (distinctMap.isEmpty) 0 else distinctMap.keySet.max + 1
/** @return The weightSum of each label in the input dataset. */
def histogram: Array[Double] = {