Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/3374#discussion_r20627362
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/tree/GradientBoostedTreesSuite.scala
---
@@ -23,104 +23,95 @@ import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.mllib.tree.configuration.Algo._
import org.apache.spark.mllib.tree.configuration.{BoostingStrategy,
Strategy}
import org.apache.spark.mllib.tree.impurity.Variance
-import org.apache.spark.mllib.tree.loss.{SquaredError, LogLoss}
+import org.apache.spark.mllib.tree.loss.{AbsoluteError, SquaredError,
LogLoss}
import org.apache.spark.mllib.util.MLlibTestSparkContext
/**
- * Test suite for [[GradientBoosting]].
+ * Test suite for [[GradientBoostedTrees]].
*/
-class GradientBoostingSuite extends FunSuite with MLlibTestSparkContext {
+class GradientBoostedTreesSuite extends FunSuite with
MLlibTestSparkContext {
test("Regression with continuous features: SquaredError") {
- GradientBoostingSuite.testCombinations.foreach {
+ GradientBoostedTreesSuite.testCombinations.foreach {
case (numIterations, learningRate, subsamplingRate) =>
val arr =
EnsembleTestHelper.generateOrderedLabeledPoints(numFeatures = 10, 100)
- val rdd = sc.parallelize(arr)
- val categoricalFeaturesInfo = Map.empty[Int, Int]
+ val rdd = sc.parallelize(arr, 2)
- val remappedInput = rdd.map(x => new LabeledPoint((x.label * 2) -
1, x.features))
val treeStrategy = new Strategy(algo = Regression, impurity =
Variance, maxDepth = 2,
- numClassesForClassification = 2, categoricalFeaturesInfo =
categoricalFeaturesInfo,
- subsamplingRate = subsamplingRate)
-
- val dt = DecisionTree.train(remappedInput, treeStrategy)
-
- val boostingStrategy = new BoostingStrategy(Regression,
numIterations, SquaredError,
- learningRate, 1, treeStrategy)
+ categoricalFeaturesInfo = Map.empty, subsamplingRate =
subsamplingRate)
+ val boostingStrategy =
+ new BoostingStrategy(treeStrategy, SquaredError, numIterations,
learningRate)
- val gbt = GradientBoosting.trainRegressor(rdd, boostingStrategy)
- assert(gbt.weakHypotheses.size === numIterations)
- val gbtTree = gbt.weakHypotheses(0)
+ val gbt = GradientBoostedTrees.train(rdd, boostingStrategy)
+ assert(gbt.trees.size === numIterations)
EnsembleTestHelper.validateRegressor(gbt, arr, 0.03)
+ val remappedInput = rdd.map(x => new LabeledPoint((x.label * 2) -
1, x.features))
+ val dt = DecisionTree.train(remappedInput, treeStrategy)
+
// Make sure trees are the same.
- assert(gbtTree.toString == dt.toString)
+ assert(gbt.trees.head.toString == dt.toString)
}
}
test("Regression with continuous features: Absolute Error") {
- GradientBoostingSuite.testCombinations.foreach {
+ GradientBoostedTreesSuite.testCombinations.foreach {
case (numIterations, learningRate, subsamplingRate) =>
val arr =
EnsembleTestHelper.generateOrderedLabeledPoints(numFeatures = 10, 100)
- val rdd = sc.parallelize(arr)
- val categoricalFeaturesInfo = Map.empty[Int, Int]
+ val rdd = sc.parallelize(arr, 2)
- val remappedInput = rdd.map(x => new LabeledPoint((x.label * 2) -
1, x.features))
val treeStrategy = new Strategy(algo = Regression, impurity =
Variance, maxDepth = 2,
- numClassesForClassification = 2, categoricalFeaturesInfo =
categoricalFeaturesInfo,
- subsamplingRate = subsamplingRate)
-
- val dt = DecisionTree.train(remappedInput, treeStrategy)
+ categoricalFeaturesInfo = Map.empty, subsamplingRate =
subsamplingRate)
+ val boostingStrategy =
+ new BoostingStrategy(treeStrategy, AbsoluteError, numIterations,
learningRate)
- val boostingStrategy = new BoostingStrategy(Regression,
numIterations, SquaredError,
--- End diff --
@manishamde Thanks for checking this test! Let's fix it in a separate PR.
We are going to cut a release candidate and I hope we can update the API before
that. Let me know when you finish a pass, I will update the PR following your
suggestions.
---
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]