Github user sethah commented on a diff in the pull request:
https://github.com/apache/spark/pull/9008#discussion_r53092853
--- Diff:
mllib/src/test/scala/org/apache/spark/ml/regression/RandomForestRegressorSuite.scala
---
@@ -101,6 +104,43 @@ class RandomForestRegressorSuite extends SparkFunSuite
with MLlibTestSparkContex
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(10)(Instance(10, 0.1, keyFeature))
+ val data1 = Array.fill(10)(Instance(20, 20.0, keyFeature))
+
+ val testData = Seq(Instance(0, 1, keyFeature))
+ (sqlContext.createDataFrame(sc.parallelize(data0 ++ data1, 2)),
+ sqlContext.createDataFrame(sc.parallelize(testData, 2)))
+ }
+
+ val featureIndexer = new VectorIndexer()
+ .setInputCol("features")
+ .setOutputCol("indexedFeatures")
+ .setMaxCategories(4)
+ .fit(dataset)
+
+ val rf = new RandomForestRegressor()
+ .setFeaturesCol("indexedFeatures")
+ .setPredictionCol("predictedLabel")
+ .setSeed(1)
+
+ val pipeline = new Pipeline()
+ .setStages(Array(featureIndexer, rf))
+
+ val model1 = pipeline.fit(dataset)
+ val model2 = pipeline.fit(dataset, rf.weightCol->"weight")
--- End diff --
ditto
---
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]