Skip to content

Commit

Permalink
remove numBins field in the Strategy class
Browse files Browse the repository at this point in the history
  • Loading branch information
manishamde committed Apr 1, 2014
1 parent 7d54b4f commit 1e8c704
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ class DecisionTree private(val strategy: Strategy) extends Serializable with Log
val (splits, bins) = DecisionTree.findSplitsBins(input, strategy)
logDebug("numSplits = " + bins(0).length)

// Set number of bins for the input data.
strategy.numBins = bins(0).length

// depth of the decision tree
val maxDepth = strategy.maxDepth
// the max number of nodes possible given the depth of the tree
Expand Down Expand Up @@ -300,7 +297,7 @@ object DecisionTree extends Serializable with Logging {
// Find the number of features by looking at the first sample.
val numFeatures = input.first().features.length
logDebug("numFeatures = " + numFeatures)
val numBins = strategy.numBins
val numBins = bins(0).length
logDebug("numBins = " + numBins)

/** Find the filters used before reaching the current code. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ class Strategy (
val maxDepth: Int,
val maxBins: Int = 100,
val quantileCalculationStrategy: QuantileStrategy = Sort,
val categoricalFeaturesInfo: Map[Int,Int] = Map[Int,Int]()) extends Serializable {

var numBins: Int = Int.MinValue
}
val categoricalFeaturesInfo: Map[Int,Int] = Map[Int,Int]()) extends Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ class DecisionTreeSuite extends FunSuite with BeforeAndAfterAll {
maxBins = 100,
categoricalFeaturesInfo = Map(0 -> 3, 1-> 3))
val (splits, bins) = DecisionTree.findSplitsBins(rdd, strategy)
strategy.numBins = 100
val bestSplits = DecisionTree.findBestSplits(rdd, new Array(7), strategy, 0,
Array[List[Filter]](), splits, bins)

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

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

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

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

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

strategy.numBins = 100
val bestSplits = DecisionTree.findBestSplits(rdd, Array(0.0), strategy, 0,
Array[List[Filter]](), splits, bins)
assert(bestSplits.length === 1)
Expand Down

0 comments on commit 1e8c704

Please sign in to comment.