Skip to content

Commit 1e8c704

Browse files
committed
remove numBins field in the Strategy class
1 parent 7d54b4f commit 1e8c704

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ class DecisionTree private(val strategy: Strategy) extends Serializable with Log
5656
val (splits, bins) = DecisionTree.findSplitsBins(input, strategy)
5757
logDebug("numSplits = " + bins(0).length)
5858

59-
// Set number of bins for the input data.
60-
strategy.numBins = bins(0).length
61-
6259
// depth of the decision tree
6360
val maxDepth = strategy.maxDepth
6461
// the max number of nodes possible given the depth of the tree
@@ -300,7 +297,7 @@ object DecisionTree extends Serializable with Logging {
300297
// Find the number of features by looking at the first sample.
301298
val numFeatures = input.first().features.length
302299
logDebug("numFeatures = " + numFeatures)
303-
val numBins = strategy.numBins
300+
val numBins = bins(0).length
304301
logDebug("numBins = " + numBins)
305302

306303
/** Find the filters used before reaching the current code. */

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/Strategy.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,4 @@ class Strategy (
4040
val maxDepth: Int,
4141
val maxBins: Int = 100,
4242
val quantileCalculationStrategy: QuantileStrategy = Sort,
43-
val categoricalFeaturesInfo: Map[Int,Int] = Map[Int,Int]()) extends Serializable {
44-
45-
var numBins: Int = Int.MinValue
46-
}
43+
val categoricalFeaturesInfo: Map[Int,Int] = Map[Int,Int]()) extends Serializable

mllib/src/test/scala/org/apache/spark/mllib/tree/DecisionTreeSuite.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
252252
maxBins = 100,
253253
categoricalFeaturesInfo = Map(0 -> 3, 1-> 3))
254254
val (splits, bins) = DecisionTree.findSplitsBins(rdd, strategy)
255-
strategy.numBins = 100
256255
val bestSplits = DecisionTree.findBestSplits(rdd, new Array(7), strategy, 0,
257256
Array[List[Filter]](), splits, bins)
258257

@@ -280,7 +279,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
280279
maxBins = 100,
281280
categoricalFeaturesInfo = Map(0 -> 3, 1-> 3))
282281
val (splits, bins) = DecisionTree.findSplitsBins(rdd,strategy)
283-
strategy.numBins = 100
284282
val bestSplits = DecisionTree.findBestSplits(rdd, new Array(7), strategy, 0,
285283
Array[List[Filter]](), splits, bins)
286284

@@ -310,7 +308,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
310308
assert(splits(0).length === 99)
311309
assert(bins(0).length === 100)
312310

313-
strategy.numBins = 100
314311
val bestSplits = DecisionTree.findBestSplits(rdd, new Array(7), strategy, 0,
315312
Array[List[Filter]](), splits, bins)
316313
assert(bestSplits.length === 1)
@@ -334,7 +331,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
334331
assert(splits(0).length === 99)
335332
assert(bins(0).length === 100)
336333

337-
strategy.numBins = 100
338334
val bestSplits = DecisionTree.findBestSplits(rdd, Array(0.0), strategy, 0,
339335
Array[List[Filter]](), splits, bins)
340336
assert(bestSplits.length === 1)
@@ -359,7 +355,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
359355
assert(splits(0).length === 99)
360356
assert(bins(0).length === 100)
361357

362-
strategy.numBins = 100
363358
val bestSplits = DecisionTree.findBestSplits(rdd, Array(0.0), strategy, 0,
364359
Array[List[Filter]](), splits, bins)
365360
assert(bestSplits.length === 1)
@@ -384,7 +379,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
384379
assert(splits(0).length === 99)
385380
assert(bins(0).length === 100)
386381

387-
strategy.numBins = 100
388382
val bestSplits = DecisionTree.findBestSplits(rdd, Array(0.0), strategy, 0,
389383
Array[List[Filter]](), splits, bins)
390384
assert(bestSplits.length === 1)

0 commit comments

Comments
 (0)