Skip to content
Snippets Groups Projects
Commit d4cb38ae authored by Alain's avatar Alain Committed by Sean Owen
Browse files

[MLLIB] [TREE] Verify size of input rdd > 0 when building meta data

Require non empty input rdd such that we can take the first labeledpoint and get the feature size

Author: Alain <aihe@usc.edu>
Author: aihe@usc.edu <aihe@usc.edu>

Closes #5810 from AiHe/decisiontree-issue and squashes the following commits:

3b1d08a [aihe@usc.edu] [MLLIB][tree] merge the assertion into the evaluation of numFeatures
cf2e567 [Alain] [MLLIB][tree] Use a rdd api to verify size of input rdd > 0 when building meta data
b448f47 [Alain] [MLLIB][tree] Verify size of input rdd > 0 when building meta data
parent 9d250e64
No related branches found
No related tags found
No related merge requests found
......@@ -107,7 +107,10 @@ private[tree] object DecisionTreeMetadata extends Logging {
numTrees: Int,
featureSubsetStrategy: String): DecisionTreeMetadata = {
val numFeatures = input.take(1)(0).features.size
val numFeatures = input.map(_.features.size).take(1).headOption.getOrElse {
throw new IllegalArgumentException(s"DecisionTree requires size of input RDD > 0, " +
s"but was given by empty one.")
}
val numExamples = input.count()
val numClasses = strategy.algo match {
case Classification => strategy.numClasses
......
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