Github user chouqin commented on the pull request:

    https://github.com/apache/spark/pull/2595#issuecomment-57423431
  
    I don't know why unit test for pyspark has failed, I have tested in Scala 
using the same test data, and it passes. For example here is code I wrote:
    
    ```scala
       // this data is correspond to data defined at pyspark/mllib/tests.py: 
line 125
        val arr = new Array[LabeledPoint](4)
        arr(0) = new LabeledPoint(0.0, Vectors.dense(1.0, 0.0, 0.0))
        arr(1) = new LabeledPoint(1.0, Vectors.dense(0.0, 1.0, 1.0))
        arr(2) = new LabeledPoint(0.0, Vectors.dense(2.0, 0.0, 0.0))
        arr(3) = new LabeledPoint(1.0, Vectors.dense(0.0, 2.0, 1.0))
        val input = sc.parallelize(arr)
    
        // these parameters are correspond to DecisionTree.trainClassifier at 
pyspark/mllib/tests.py: line 154
        val strategy = new Strategy(algo = Classification, impurity = Gini, 
maxDepth=5,
          numClassesForClassification = 2, categoricalFeaturesInfo = Map(0 -> 
3))
        val model = DecisionTree.train(input, strategy)
    
       // these asserts will pass
        assert(model.predict(arr(0).features) == 0.0)
        assert(model.predict(arr(1).features) == 1.0)
        assert(model.predict(arr(2).features) == 0.0)
        assert(model.predict(arr(3).features) == 1.0)
    ```


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to