Skip to content
Closed
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
Deprecate DT/RF/GBT setter methods in the Model classes
  • Loading branch information
yanboliang committed Nov 26, 2016
commit 39cbf4267d9d136f6a16f85e8e2d88939a35e22f
86 changes: 67 additions & 19 deletions mllib/src/main/scala/org/apache/spark/ml/tree/treeParams.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,41 @@ private[ml] trait DecisionTreeParams extends PredictorParams
setDefault(maxDepth -> 5, maxBins -> 32, minInstancesPerNode -> 1, minInfoGain -> 0.0,
maxMemoryInMB -> 256, cacheNodeIds -> false, checkpointInterval -> 10)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
Copy link
Member

Choose a reason for hiding this comment

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

Does this appear as deprecated in the Estimator classes? If so, then can you update the comment to make it clear it is only deprecated for Models?

Copy link
Member

Choose a reason for hiding this comment

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

Actually, if this is a problem, we could mark the setters in Models as deprecated and leave the treeParams alone since the treeParams traits are private.

Copy link
Contributor Author

@yanboliang yanboliang Nov 29, 2016

Choose a reason for hiding this comment

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

This will not appear in estimator classes, only in models. This can be confirmed by the following ways:
The IDE will prompt deprecated methods only for models:
image
We can also confirm it in Scala API docs:
DecisionTreeClassifier
image
DecisionTreeClassificationModel
image

Copy link
Member

Choose a reason for hiding this comment

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

Great, thank you for checking!

def setMaxDepth(value: Int): this.type = set(maxDepth, value)

/** @group getParam */
final def getMaxDepth: Int = $(maxDepth)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setMaxBins(value: Int): this.type = set(maxBins, value)

/** @group getParam */
final def getMaxBins: Int = $(maxBins)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setMinInstancesPerNode(value: Int): this.type = set(minInstancesPerNode, value)

/** @group getParam */
final def getMinInstancesPerNode: Int = $(minInstancesPerNode)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setMinInfoGain(value: Double): this.type = set(minInfoGain, value)

/** @group getParam */
Expand All @@ -134,27 +150,31 @@ private[ml] trait DecisionTreeParams extends PredictorParams
/** @group setParam */
def setSeed(value: Long): this.type = set(seed, value)
Copy link
Member

Choose a reason for hiding this comment

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

Are you intentionally keeping setSeed in Models?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, I missed it and will add it. Thanks.


/** @group expertSetParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group expertSetParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setMaxMemoryInMB(value: Int): this.type = set(maxMemoryInMB, value)

/** @group expertGetParam */
final def getMaxMemoryInMB: Int = $(maxMemoryInMB)

/** @group expertSetParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group expertSetParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setCacheNodeIds(value: Boolean): this.type = set(cacheNodeIds, value)

/** @group expertGetParam */
final def getCacheNodeIds: Boolean = $(cacheNodeIds)

/**
* Specifies how often to checkpoint the cached node IDs.
* E.g. 10 means that the cache will get checkpointed every 10 iterations.
* This is only used if cacheNodeIds is true and if the checkpoint directory is set in
* [[org.apache.spark.SparkContext]].
* Must be >= 1.
* (default = 10)
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setCheckpointInterval(value: Int): this.type = set(checkpointInterval, value)

/** (private[ml]) Create a Strategy instance to use with the old API. */
Expand Down Expand Up @@ -198,7 +218,11 @@ private[ml] trait TreeClassifierParams extends Params {

setDefault(impurity -> "gini")

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setImpurity(value: String): this.type = set(impurity, value)

/** @group getParam */
Expand Down Expand Up @@ -243,7 +267,11 @@ private[ml] trait TreeRegressorParams extends Params {

setDefault(impurity -> "variance")

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setImpurity(value: String): this.type = set(impurity, value)

/** @group getParam */
Expand Down Expand Up @@ -300,7 +328,11 @@ private[ml] trait TreeEnsembleParams extends DecisionTreeParams {

setDefault(subsamplingRate -> 1.0)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setSubsamplingRate(value: Double): this.type = set(subsamplingRate, value)

/** @group getParam */
Expand Down Expand Up @@ -340,7 +372,11 @@ private[ml] trait RandomForestParams extends TreeEnsembleParams {

setDefault(numTrees -> 20)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setNumTrees(value: Int): this.type = set(numTrees, value)

/** @group getParam */
Expand Down Expand Up @@ -383,7 +419,11 @@ private[ml] trait RandomForestParams extends TreeEnsembleParams {

setDefault(featureSubsetStrategy -> "auto")

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setFeatureSubsetStrategy(value: String): this.type = set(featureSubsetStrategy, value)

/** @group getParam */
Expand Down Expand Up @@ -420,7 +460,11 @@ private[ml] trait GBTParams extends TreeEnsembleParams with HasMaxIter {
// final val validationTol: DoubleParam = new DoubleParam(this, "validationTol", "")
// validationTol -> 1e-5

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setMaxIter(value: Int): this.type = set(maxIter, value)

/**
Expand All @@ -436,7 +480,11 @@ private[ml] trait GBTParams extends TreeEnsembleParams with HasMaxIter {
/** @group getParam */
final def getStepSize: Double = $(stepSize)

/** @group setParam */
/**
* @deprecated This method is deprecated and will be removed in 2.2.0.
* @group setParam
*/
@deprecated("This method is deprecated and will be removed in 2.2.0.", "2.1.0")
def setStepSize(value: Double): this.type = set(stepSize, value)

setDefault(maxIter -> 20, stepSize -> 0.1)
Expand Down