diff options
author | wm624@hotmail.com <wm624@hotmail.com> | 2016-05-14 09:45:56 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-05-14 09:45:56 +0100 |
commit | 354f8f11bd4b20fa99bd67a98da3525fd3d75c81 (patch) | |
tree | 91811f926f3b46d39efe908f1468e4c4bc74bc28 /mllib/src/test | |
parent | 0f1f31d3a6669fbac474518cf2a871485e202bdc (diff) | |
download | spark-354f8f11bd4b20fa99bd67a98da3525fd3d75c81.tar.gz spark-354f8f11bd4b20fa99bd67a98da3525fd3d75c81.tar.bz2 spark-354f8f11bd4b20fa99bd67a98da3525fd3d75c81.zip |
[SPARK-15096][ML] LogisticRegression MultiClassSummarizer numClasses can fail if no valid labels are found
## What changes were proposed in this pull request?
(Please fill in changes proposed in this fix)
Throw better exception when numClasses is empty and empty.max is thrown.
## How was this patch tested?
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
Add a new unit test, which calls histogram with empty numClasses.
Author: wm624@hotmail.com <wm624@hotmail.com>
Closes #12969 from wangmiao1981/logisticR.
Diffstat (limited to 'mllib/src/test')
-rw-r--r-- | mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala b/mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala index f127aa217c..69650ebb36 100644 --- a/mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/ml/classification/LogisticRegressionSuite.scala @@ -256,6 +256,10 @@ class LogisticRegressionSuite assert(summarizer4.countInvalid === 2) assert(summarizer4.numClasses === 4) + val summarizer5 = new MultiClassSummarizer + assert(summarizer5.histogram.isEmpty) + assert(summarizer5.numClasses === 0) + // small map merges large one val summarizerA = summarizer1.merge(summarizer2) assert(summarizerA.hashCode() === summarizer2.hashCode()) |