Github user MechCoder commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12374#discussion_r71615972
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/tree/impl/RandomForestSuite.scala ---
    @@ -137,14 +137,47 @@ class RandomForestSuite extends SparkFunSuite with 
MLlibTestSparkContext {
         {
           val fakeMetadata = new DecisionTreeMetadata(1, 0, 0, 0,
             Map(), Set(),
    -        Array(3), Gini, QuantileStrategy.Sort,
    +        Array(2), Gini, QuantileStrategy.Sort,
             0, 0, 0.0, 0, 0
           )
           val featureSamples = Array(0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
2).map(_.toDouble)
           val splits = 
RandomForest.findSplitsForContinuousFeature(featureSamples, fakeMetadata, 0)
           assert(splits.length === 1)
           assert(splits(0) === 1.0)
         }
    +
    +    // find splits for constant feature
    +    {
    +      val fakeMetadata = new DecisionTreeMetadata(1, 0, 0, 0,
    +        Map(), Set(),
    +        Array(3), Gini, QuantileStrategy.Sort,
    +        0, 0, 0.0, 0, 0
    +      )
    +      val featureSamples = Array(0, 0, 0).map(_.toDouble)
    +      val featureSamplesEmpty = Array.empty[Double]
    +      val splits = 
RandomForest.findSplitsForContinuousFeature(featureSamples, fakeMetadata, 0)
    +      assert(splits === Array[Double]())
    +      val splitsEmpty =
    +        RandomForest.findSplitsForContinuousFeature(featureSamplesEmpty, 
fakeMetadata, 0)
    +      assert(splitsEmpty === Array[Double]())
    +    }
    +  }
    +
    +  test("train with constant features") {
    +    val lp = LabeledPoint(1.0, Vectors.dense(0.0, 0.0, 0.0))
    +    val data = Array.fill(5)(lp)
    +    val rdd = sc.parallelize(data)
    +    val strategy = new OldStrategy(
    +          OldAlgo.Classification,
    +          Gini,
    +          maxDepth = 2,
    +          numClasses = 100,
    --- End diff --
    
    Is it the case that `numClasses` can be greater than the number of unique 
labels in the data. If yes, then ignore the comment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to