You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/01/13 03:44:29 UTC

[GitHub] [spark] zhengruifeng commented on pull request #31163: [SPARK-34093][ML] param maxDepth should check upper bound

zhengruifeng commented on pull request #31163:
URL: https://github.com/apache/spark/pull/31163#issuecomment-759185176


   ```
   
   scala> import org.apache.spark.ml.classification._
   import org.apache.spark.ml.classification._
   
   scala> 
   
   scala> val df = spark.read.format("libsvm").load("/d0/Dev/Opensource/spark/data/mllib/sample_multiclass_classification_data.txt")
   21/01/13 11:40:35 WARN LibSVMFileFormat: 'numFeatures' option not specified, determining the number of features by going though the input. If you know the number in advance, please specify it via 'numFeatures' option to avoid the extra scan.
   df: org.apache.spark.sql.DataFrame = [label: double, features: vector]
   
   scala> val dt = new DecisionTreeClassifi
   DecisionTreeClassificationModel   DecisionTreeClassifier
   
   scala> val dt = new DecisionTreeClassifier().setMax
   setMaxBins   setMaxDepth   setMaxMemoryInMB
   
   scala> val dt = new DecisionTreeClassifier().setMaxDepth(32)
   dt: org.apache.spark.ml.classification.DecisionTreeClassifier = dtc_9ad3d8b78d64
   
   scala> dt.fit(df)
   21/01/13 11:41:01 ERROR Instrumentation: java.lang.IllegalArgumentException: requirement failed: DecisionTree currently only supports maxDepth <= 30, but was given maxDepth = 32.
   	at scala.Predef$.require(Predef.scala:281)
   	at org.apache.spark.ml.tree.impl.RandomForest$.runBagged(RandomForest.scala:145)
   	at org.apache.spark.ml.tree.impl.RandomForest$.run(RandomForest.scala:302)
   	at org.apache.spark.ml.classification.DecisionTreeClassifier.$anonfun$train$1(DecisionTreeClassifier.scala:135)
   	at org.apache.spark.ml.util.Instrumentation$.$anonfun$instrumented$1(Instrumentation.scala:191)
   	at scala.util.Try$.apply(Try.scala:213)
   	at org.apache.spark.ml.util.Instrumentation$.instrumented(Instrumentation.scala:191)
   	at org.apache.spark.ml.classification.DecisionTreeClassifier.train(DecisionTreeClassifier.scala:114)
   	at org.apache.spark.ml.classification.DecisionTreeClassifier.train(DecisionTreeClassifier.scala:46)
   	at org.apache.spark.ml.Predictor.fit(Predictor.scala:150)
   	at $line21.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw.<init>(<console>:31)
   	at $line21.$read$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw$$iw.<init>(<console>:35)
   
   
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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