Skip to content
Snippets Groups Projects
Commit d9e0919d authored by Zheng RuiFeng's avatar Zheng RuiFeng Committed by Yanbo Liang
Browse files

[SPARK-16851][ML] Incorrect threshould length in 'setThresholds()' evoke Exception

## What changes were proposed in this pull request?
Add a length checking for threshoulds' length in method `setThreshoulds()`  of classification models.

## How was this patch tested?
unit tests

Author: Zheng RuiFeng <ruifengz@foxmail.com>

Closes #14457 from zhengruifeng/check_setThresholds.
parent a1ff72e1
No related branches found
No related tags found
No related merge requests found
......@@ -83,7 +83,12 @@ abstract class ProbabilisticClassificationModel[
def setProbabilityCol(value: String): M = set(probabilityCol, value).asInstanceOf[M]
/** @group setParam */
def setThresholds(value: Array[Double]): M = set(thresholds, value).asInstanceOf[M]
def setThresholds(value: Array[Double]): M = {
require(value.length == numClasses, this.getClass.getSimpleName +
".setThresholds() called with non-matching numClasses and thresholds.length." +
s" numClasses=$numClasses, but thresholds has length ${value.length}")
set(thresholds, value).asInstanceOf[M]
}
/**
* Transforms dataset by reading from [[featuresCol]], and appending new columns as specified by
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment