[SPARK-34093][ML] param maxDepth should check upper bound

### What changes were proposed in this pull request?
update the ParamValidators of `maxDepth`

### Why are the changes needed?
current impl of tree models only support maxDepth<=30

### Does this PR introduce _any_ user-facing change?
If `maxDepth`>30, fail quickly

### How was this patch tested?
existing testsuites

Closes #31163 from zhengruifeng/param_maxDepth_upbound.

Authored-by: Ruifeng Zheng <ruifengz@foxmail.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
This commit is contained in:
Ruifeng Zheng 2021-01-18 11:36:10 -06:00 committed by Sean Owen
parent dee596e3ef
commit d8cbef1abf
2 changed files with 5 additions and 3 deletions

View file

@ -60,8 +60,9 @@ private[ml] trait DecisionTreeParams extends PredictorParams
*/
final val maxDepth: IntParam =
new IntParam(this, "maxDepth", "Maximum depth of the tree. (Nonnegative)" +
" E.g., depth 0 means 1 leaf node; depth 1 means 1 internal node + 2 leaf nodes.",
ParamValidators.gtEq(0))
" E.g., depth 0 means 1 leaf node; depth 1 means 1 internal node + 2 leaf nodes." +
" Must be in range [0, 30].",
ParamValidators.inRange(0, 30))
/**
* Maximum number of bins used for discretizing continuous features and for choosing how to split

View file

@ -67,7 +67,8 @@ class _DecisionTreeParams(HasCheckpointInterval, HasSeed, HasWeightCol):
typeConverter=TypeConverters.toString)
maxDepth = Param(Params._dummy(), "maxDepth", "Maximum depth of the tree. (>= 0) E.g., " +
"depth 0 means 1 leaf node; depth 1 means 1 internal node + 2 leaf nodes.",
"depth 0 means 1 leaf node; depth 1 means 1 internal node + 2 leaf nodes. " +
"Must be in range [0, 30].",
typeConverter=TypeConverters.toInt)
maxBins = Param(Params._dummy(), "maxBins", "Max number of bins for discretizing continuous " +