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

    https://github.com/apache/spark/pull/9008#discussion_r53091878
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/classification/RandomForestClassifierSuite.scala
 ---
    @@ -182,6 +184,53 @@ class RandomForestClassifierSuite extends 
SparkFunSuite with MLlibTestSparkConte
         assert(mostImportantFeature === 1)
       }
     
    +  test("training with weighted data") {
    +    val (dataset, testDataset) = {
    +      val keyFeature = Vectors.dense(0, 1.0, 2, 1.2)
    +      val data0 = Array.fill(20)(Instance(0, 0.1, keyFeature))
    +      val data1 = Array.fill(10)(Instance(1, 20.0, keyFeature))
    +
    +      val testData = Seq(Instance(0, 0.1, keyFeature))
    +      (sqlContext.createDataFrame(sc.parallelize(data0 ++ data1, 2)),
    +        sqlContext.createDataFrame(sc.parallelize(testData, 2)))
    +    }
    +
    +    val labelIndexer = new StringIndexer()
    +      .setInputCol("label")
    +      .setOutputCol("indexedLabel")
    +      .fit(dataset)
    +
    +    val featureIndexer = new VectorIndexer()
    +      .setInputCol("features")
    +      .setOutputCol("indexedFeatures")
    +      .setMaxCategories(4)
    +      .fit(dataset)
    +
    +    val rf = new RandomForestClassifier()
    +      .setLabelCol("indexedLabel")
    +      .setFeaturesCol("indexedFeatures")
    +      .setSeed(1)
    +
    +    val labelConverter = new IndexToString()
    +      .setInputCol("prediction")
    +      .setOutputCol("predictedLabel")
    +      .setLabels(labelIndexer.labels)
    +
    +    val pipeline = new Pipeline()
    +      .setStages(Array(labelIndexer, featureIndexer, rf, labelConverter))
    +
    +    val model1 = pipeline.fit(dataset)
    +    val model2 = pipeline.fit(dataset, rf.weightCol->"weight")
    --- End diff --
    
    ditto: space around `->`


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