-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-18592][ML] Move DT/RF/GBT Param setter methods to subclasses #16017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Deprecate DT/RF/GBT setter methods in the Model classes
- Loading branch information
commit 39cbf4267d9d136f6a16f85e8e2d88939a35e22f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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") | ||
| 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 */ | ||
|
|
@@ -134,27 +150,31 @@ private[ml] trait DecisionTreeParams extends PredictorParams | |
| /** @group setParam */ | ||
| def setSeed(value: Long): this.type = set(seed, value) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you intentionally keeping setSeed in Models?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. */ | ||
|
|
@@ -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 */ | ||
|
|
@@ -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 */ | ||
|
|
@@ -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 */ | ||
|
|
@@ -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 */ | ||
|
|
@@ -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 */ | ||
|
|
@@ -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) | ||
|
|
||
| /** | ||
|
|
@@ -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) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:
We can also confirm it in Scala API docs:
DecisionTreeClassifierDecisionTreeClassificationModelThere was a problem hiding this comment.
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!