-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-10266][Documentation, ML] Fixed @Since annotation for ml.tunning #8729
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 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1063243
Since annotation for ml.regression
ehsanmok 40dc4f2
Since annotation for ml.tuning
ehsanmok eb4f580
indentations fixed
ehsanmok 338bbf8
coding style fixed
ehsanmok a35ec08
update master
ehsanmok 27c9cc8
renewed commits for JIRA-10266
ehsanmok 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
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
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 |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ package org.apache.spark.ml.regression | |
| import com.github.fommil.netlib.BLAS.{getInstance => blas} | ||
|
|
||
| import org.apache.spark.Logging | ||
| import org.apache.spark.annotation.Experimental | ||
| import org.apache.spark.annotation.{Experimental, Since} | ||
| import org.apache.spark.ml.{PredictionModel, Predictor} | ||
| import org.apache.spark.ml.param.{Param, ParamMap} | ||
| import org.apache.spark.ml.tree.{DecisionTreeModel, GBTParams, TreeEnsembleModel, TreeRegressorParams} | ||
|
|
@@ -42,54 +42,56 @@ import org.apache.spark.sql.types.DoubleType | |
| * learning algorithm for regression. | ||
| * It supports both continuous and categorical features. | ||
| */ | ||
| @Since("1.4.0") | ||
| @Experimental | ||
| final class GBTRegressor(override val uid: String) | ||
| final class GBTRegressor @Since("1.4.0") (@Since("1.4.0") override val uid: String) | ||
| extends Predictor[Vector, GBTRegressor, GBTRegressionModel] | ||
| with GBTParams with TreeRegressorParams with Logging { | ||
|
|
||
| @Since("1.4.0") | ||
| def this() = this(Identifiable.randomUID("gbtr")) | ||
|
|
||
| // Override parameter setters from parent trait for Java API compatibility. | ||
|
|
||
| // Parameters from TreeRegressorParams: | ||
|
|
||
| @Since("1.4.0") | ||
| override def setMaxDepth(value: Int): this.type = super.setMaxDepth(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setMaxBins(value: Int): this.type = super.setMaxBins(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setMinInstancesPerNode(value: Int): this.type = | ||
| super.setMinInstancesPerNode(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setMinInfoGain(value: Double): this.type = super.setMinInfoGain(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setMaxMemoryInMB(value: Int): this.type = super.setMaxMemoryInMB(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setCacheNodeIds(value: Boolean): this.type = super.setCacheNodeIds(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setCheckpointInterval(value: Int): this.type = super.setCheckpointInterval(value) | ||
|
|
||
| /** | ||
| * The impurity setting is ignored for GBT models. | ||
| * Individual trees are built using impurity "Variance." | ||
| */ | ||
| @Since("1.4.0") | ||
| override def setImpurity(value: String): this.type = { | ||
| logWarning("GBTRegressor.setImpurity should NOT be used") | ||
| this | ||
| } | ||
|
|
||
| // Parameters from TreeEnsembleParams: | ||
|
|
||
| @Since("1.4.0") | ||
| override def setSubsamplingRate(value: Double): this.type = super.setSubsamplingRate(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setSeed(value: Long): this.type = { | ||
| logWarning("The 'seed' parameter is currently ignored by Gradient Boosting.") | ||
| super.setSeed(value) | ||
| } | ||
|
|
||
| // Parameters from GBTParams: | ||
|
|
||
| @Since("1.4.0") | ||
| override def setMaxIter(value: Int): this.type = super.setMaxIter(value) | ||
|
|
||
| @Since("1.4.0") | ||
| override def setStepSize(value: Double): this.type = super.setStepSize(value) | ||
|
|
||
| // Parameters for GBTRegressor: | ||
|
|
@@ -108,9 +110,11 @@ final class GBTRegressor(override val uid: String) | |
| setDefault(lossType -> "squared") | ||
|
|
||
| /** @group setParam */ | ||
| @Since("1.4.0") | ||
| def setLossType(value: String): this.type = set(lossType, value) | ||
|
|
||
| /** @group getParam */ | ||
| @Since("1.4.0") | ||
| def getLossType: String = $(lossType).toLowerCase | ||
|
|
||
| /** (private[ml]) Convert new loss to old loss. */ | ||
|
|
@@ -133,10 +137,11 @@ final class GBTRegressor(override val uid: String) | |
| val oldModel = oldGBT.run(oldDataset) | ||
| GBTRegressionModel.fromOld(oldModel, this, categoricalFeatures) | ||
| } | ||
|
|
||
| @Since("1.4.0") | ||
| override def copy(extra: ParamMap): GBTRegressor = defaultCopy(extra) | ||
| } | ||
|
|
||
| @Since("1.4.0") | ||
| @Experimental | ||
| object GBTRegressor { | ||
| // The losses below should be lowercase. | ||
|
|
@@ -153,20 +158,21 @@ object GBTRegressor { | |
| * @param _trees Decision trees in the ensemble. | ||
| * @param _treeWeights Weights for the decision trees in the ensemble. | ||
| */ | ||
| @Since("1.4.0") | ||
| @Experimental | ||
| final class GBTRegressionModel( | ||
| override val uid: String, | ||
| private val _trees: Array[DecisionTreeRegressionModel], | ||
| private val _treeWeights: Array[Double]) | ||
| final class GBTRegressionModel @Since("1.4.0") ( | ||
| @Since("1.4.0") override val uid: String, | ||
| private val _trees: Array[DecisionTreeRegressionModel], | ||
| private val _treeWeights: Array[Double]) | ||
|
||
| extends PredictionModel[Vector, GBTRegressionModel] | ||
| with TreeEnsembleModel with Serializable { | ||
|
|
||
| require(numTrees > 0, "GBTRegressionModel requires at least 1 tree.") | ||
| require(_trees.length == _treeWeights.length, "GBTRegressionModel given trees, treeWeights of" + | ||
| s" non-matching lengths (${_trees.length}, ${_treeWeights.length}, respectively).") | ||
|
|
||
| @Since("1.4.0") | ||
| override def trees: Array[DecisionTreeModel] = _trees.asInstanceOf[Array[DecisionTreeModel]] | ||
|
|
||
| @Since("1.4.0") | ||
| override def treeWeights: Array[Double] = _treeWeights | ||
|
|
||
| override protected def transformImpl(dataset: DataFrame): DataFrame = { | ||
|
|
@@ -183,11 +189,11 @@ final class GBTRegressionModel( | |
| val treePredictions = _trees.map(_.rootNode.predictImpl(features).prediction) | ||
| blas.ddot(numTrees, treePredictions, 1, _treeWeights, 1) | ||
| } | ||
|
|
||
| @Since("1.4.0") | ||
| override def copy(extra: ParamMap): GBTRegressionModel = { | ||
| copyValues(new GBTRegressionModel(uid, _trees, _treeWeights), extra).setParent(parent) | ||
| } | ||
|
|
||
| @Since("1.4.0") | ||
| override def toString: String = { | ||
| s"GBTRegressionModel with $numTrees trees" | ||
| } | ||
|
|
||
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
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
Oops, something went wrong.
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.
Remove the whitespace at end of line.