Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class DecisionTreeClassifier @Since("1.4.0") (
@Since("1.4.0")
def setMinInfoGain(value: Double): this.type = set(minInfoGain, value)

/** @group setParam */
@Since("3.1.2")
def setPruneTree(value: Boolean): this.type = set(pruneTree, value)

/** @group expertSetParam */
@Since("1.4.0")
def setMaxMemoryInMB(value: Int): this.type = set(maxMemoryInMB, value)
Expand Down Expand Up @@ -126,9 +130,11 @@ class DecisionTreeClassifier @Since("1.4.0") (
val instances = extractInstances(dataset, numClasses)
val strategy = getOldStrategy(categoricalFeatures, numClasses)
require(!strategy.bootstrap, "DecisionTreeClassifier does not need bootstrap sampling")
strategy.pruneTree = $(pruneTree)

instr.logNumClasses(numClasses)
instr.logParams(this, labelCol, featuresCol, predictionCol, rawPredictionCol,
probabilityCol, leafCol, maxDepth, maxBins, minInstancesPerNode, minInfoGain,
probabilityCol, leafCol, maxDepth, maxBins, minInstancesPerNode, minInfoGain, pruneTree,
maxMemoryInMB, cacheNodeIds, checkpointInterval, impurity, seed, thresholds)

val trees = RandomForest.run(instances, strategy, numTrees = 1, featureSubsetStrategy = "all",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ class RandomForestClassifier @Since("1.4.0") (
@Since("1.4.0")
def setMinInfoGain(value: Double): this.type = set(minInfoGain, value)

/** @group setParam */
@Since("3.1.2")
def setPruneTree(value: Boolean): this.type = set(pruneTree, value)

/** @group expertSetParam */
@Since("1.4.0")
def setMaxMemoryInMB(value: Int): this.type = set(maxMemoryInMB, value)
Expand Down Expand Up @@ -152,10 +156,11 @@ class RandomForestClassifier @Since("1.4.0") (
val strategy =
super.getOldStrategy(categoricalFeatures, numClasses, OldAlgo.Classification, getOldImpurity)
strategy.bootstrap = $(bootstrap)
strategy.pruneTree = $(pruneTree)

instr.logParams(this, labelCol, featuresCol, weightCol, predictionCol, probabilityCol,
rawPredictionCol, leafCol, impurity, numTrees, featureSubsetStrategy, maxDepth, maxBins,
maxMemoryInMB, minInfoGain, minInstancesPerNode, minWeightFractionPerNode, seed,
maxMemoryInMB, minInfoGain, pruneTree, minInstancesPerNode, minWeightFractionPerNode, seed,
subsamplingRate, thresholds, cacheNodeIds, checkpointInterval, bootstrap)

val trees = RandomForest
Expand Down
Loading