Skip to content

Commit

Permalink
[MLLIB][tree] Verify size of input rdd > 0 when building meta data
Browse files Browse the repository at this point in the history
Require non empty input rdd such that we can take the first
labeledpoint and get the feature size
  • Loading branch information
Alain committed Apr 30, 2015
1 parent d188b8b commit b448f47
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ private[tree] object DecisionTreeMetadata extends Logging {
numTrees: Int,
featureSubsetStrategy: String): DecisionTreeMetadata = {

val numFeatures = input.take(1)(0).features.size
val numExamples = input.count()
require(numExamples > 0, s"DecisionTree requires size of input RDD > 0, " +
s"but was given by an empty one.")

val numFeatures = input.take(1)(0).features.size
val numClasses = strategy.algo match {
case Classification => strategy.numClasses
case Regression => 0
Expand Down

0 comments on commit b448f47

Please sign in to comment.