Description
Decision trees/GBT/RF do not handle edge cases such as constant features or empty features. For example:
val dt = new DecisionTreeRegressor() val data = Seq(LabeledPoint(1.0, Vectors.dense(Array.empty[Double]))).toDF() dt.fit(data) java.lang.UnsupportedOperationException: empty.max at scala.collection.TraversableOnce$class.max(TraversableOnce.scala:229) at scala.collection.mutable.ArrayOps$ofInt.max(ArrayOps.scala:234) at org.apache.spark.ml.tree.impl.DecisionTreeMetadata$.buildMetadata(DecisionTreeMetadata.scala:207) at org.apache.spark.ml.tree.impl.RandomForest$.run(RandomForest.scala:105) at org.apache.spark.ml.regression.DecisionTreeRegressor.train(DecisionTreeRegressor.scala:93) at org.apache.spark.ml.regression.DecisionTreeRegressor.train(DecisionTreeRegressor.scala:46) at org.apache.spark.ml.Predictor.fit(Predictor.scala:90) ... 52 elided
as well as
val dt = new DecisionTreeRegressor() val data = Seq(LabeledPoint(1.0, Vectors.dense(0.0, 0.0, 0.0))).toDF() dt.fit(data) java.lang.UnsupportedOperationException: empty.maxBy at scala.collection.TraversableOnce$class.maxBy(TraversableOnce.scala:236) at scala.collection.SeqViewLike$AbstractTransformed.maxBy(SeqViewLike.scala:37) at org.apache.spark.ml.tree.impl.RandomForest$.binsToBestSplit(RandomForest.scala:846)