Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Parameterizing max memory.
  • Loading branch information
etrain committed Apr 22, 2014
commit abc5a23bf80d792a345d723b44bff3ee217cd5ac
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.apache.spark.mllib.tree.impurity.{Entropy, Gini, Impurity, Variance}
import org.apache.spark.mllib.tree.model._
import org.apache.spark.rdd.RDD
import org.apache.spark.util.random.XORShiftRandom
import org.apache.spark.util.Utils.memoryStringToMb
import org.apache.spark.mllib.linalg.{Vector, Vectors}

/**
Expand Down Expand Up @@ -79,7 +80,7 @@ class DecisionTree (private val strategy: Strategy) extends Serializable with Lo
// Calculate level for single group construction

// Max memory usage for aggregates
val maxMemoryUsage = scala.math.pow(2, 27).toInt //128MB
val maxMemoryUsage = strategy.maxMemory * 1024 * 1024
logDebug("max memory usage for aggregates = " + maxMemoryUsage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ "bytes."?

val numElementsPerNode = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary to have an extra { } pair.

strategy.algo match {
Expand Down Expand Up @@ -1158,10 +1159,13 @@ object DecisionTree extends Serializable with Logging {

val maxDepth = options.getOrElse('maxDepth, "1").toString.toInt
val maxBins = options.getOrElse('maxBins, "100").toString.toInt
val maxMemUsage = memoryStringToMb(options.getOrElse('maxMemory, "128m").toString)

val strategy = new Strategy(algo, impurity, maxDepth, maxBins)
val strategy = new Strategy(algo, impurity, maxDepth, maxBins, maxMemory=maxMemUsage)
val model = DecisionTree.train(trainData, strategy)



// Load test data.
val testData = loadLabeledData(sc, options.get('testDataDir).get.toString)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ class Strategy (
val maxDepth: Int,
val maxBins: Int = 100,
val quantileCalculationStrategy: QuantileStrategy = Sort,
val categoricalFeaturesInfo: Map[Int, Int] = Map[Int, Int]()) extends Serializable
val categoricalFeaturesInfo: Map[Int, Int] = Map[Int, Int](),
val maxMemory: Int = 128) extends Serializable