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

    https://github.com/apache/spark/pull/8734#discussion_r48616306
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/tree/DecisionTreeSuite.scala ---
    @@ -337,12 +342,62 @@ class DecisionTreeSuite extends SparkFunSuite with 
MLlibTestSparkContext {
         assert(topNode.impurity !== -1.0)
     
         // set impurity and predict for child nodes
    -    assert(topNode.leftNode.get.predict.predict === 0.0)
    -    assert(topNode.rightNode.get.predict.predict === 1.0)
    +    if (topNode.leftNode.get.predict.predict === 0.0) {
    +      assert(topNode.rightNode.get.predict.predict === 1.0)
    +    } else {
    +      assert(topNode.leftNode.get.predict.predict === 1.0)
    +      assert(topNode.rightNode.get.predict.predict === 0.0)
    +    }
         assert(topNode.leftNode.get.impurity === 0.0)
         assert(topNode.rightNode.get.impurity === 0.0)
       }
     
    +  test("Use soft prediction for binary classification with ordered 
categorical features") {
    +    val arr = Array(
    +      LabeledPoint(0.0, Vectors.dense(1.0, 0.0, 0.0)), // left node
    +      LabeledPoint(1.0, Vectors.dense(0.0, 1.0, 1.0)), // right node
    +      LabeledPoint(0.0, Vectors.dense(2.0, 0.0, 0.0)), // left node
    +      LabeledPoint(1.0, Vectors.dense(0.0, 2.0, 1.0)), // right node
    +      LabeledPoint(1.0, Vectors.dense(1.0, 1.0, 0.0)), // left node
    +      LabeledPoint(1.0, Vectors.dense(1.0, 0.0, 2.0))) // left node
    +    val input = sc.parallelize(arr)
    +
    +    val strategy = new Strategy(algo = Classification, impurity = Gini, 
maxDepth = 1,
    +      numClasses = 2, categoricalFeaturesInfo = Map(0 -> 3))
    +    val metadata = DecisionTreeMetadata.buildMetadata(input, strategy)
    +    val (splits, bins) = DecisionTree.findSplitsBins(input, metadata)
    +
    +    val treeInput = TreePoint.convertToTreeRDD(input, bins, metadata)
    +    val baggedInput = BaggedPoint.convertToBaggedRDD(treeInput, 1.0, 1, 
false)
    +
    +    val topNode = Node.emptyNode(nodeIndex = 1)
    +    assert(topNode.predict.predict === Double.MinValue)
    +    assert(topNode.impurity === -1.0)
    +    assert(topNode.isLeaf === false)
    +
    +    val nodesForGroup = Map((0, Array(topNode)))
    +    val treeToNodeToIndexInfo = Map((0, Map(
    +      (topNode.id, new RandomForest.NodeIndexInfo(0, None))
    +    )))
    +    val nodeQueue = new mutable.Queue[(Int, Node)]()
    +    DecisionTree.findBestSplits(baggedInput, metadata, Array(topNode),
    --- End diff --
    
    Ping


---
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