Skip to content

Commit 6d8ebc8

Browse files
committed
[SPARK-10243] [MLLIB] update since versions in mllib.tree
Same as #8421 but for `mllib.tree`. cc jkbradley Author: Xiangrui Meng <[email protected]> Closes #8442 from mengxr/SPARK-10236. (cherry picked from commit fb7e12f) Signed-off-by: Xiangrui Meng <[email protected]>
1 parent be0c991 commit 6d8ebc8

File tree

12 files changed

+57
-44
lines changed

12 files changed

+57
-44
lines changed

mllib/src/main/scala/org/apache/spark/mllib/tree/DecisionTree.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import org.apache.spark.util.random.XORShiftRandom
4646
*/
4747
@Since("1.0.0")
4848
@Experimental
49-
class DecisionTree (private val strategy: Strategy) extends Serializable with Logging {
49+
class DecisionTree @Since("1.0.0") (private val strategy: Strategy)
50+
extends Serializable with Logging {
5051

5152
strategy.assertValid()
5253

mllib/src/main/scala/org/apache/spark/mllib/tree/GradientBoostedTrees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import org.apache.spark.storage.StorageLevel
5151
*/
5252
@Since("1.2.0")
5353
@Experimental
54-
class GradientBoostedTrees(private val boostingStrategy: BoostingStrategy)
54+
class GradientBoostedTrees @Since("1.2.0") (private val boostingStrategy: BoostingStrategy)
5555
extends Serializable with Logging {
5656

5757
/**

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/Algo.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ import org.apache.spark.annotation.{Experimental, Since}
2626
@Since("1.0.0")
2727
@Experimental
2828
object Algo extends Enumeration {
29+
@Since("1.0.0")
2930
type Algo = Value
31+
@Since("1.0.0")
3032
val Classification, Regression = Value
3133

3234
private[mllib] def fromString(name: String): Algo = name match {

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/BoostingStrategy.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ import org.apache.spark.mllib.tree.loss.{LogLoss, SquaredError, Loss}
4141
*/
4242
@Since("1.2.0")
4343
@Experimental
44-
case class BoostingStrategy(
44+
case class BoostingStrategy @Since("1.4.0") (
4545
// Required boosting parameters
46-
@BeanProperty var treeStrategy: Strategy,
47-
@BeanProperty var loss: Loss,
46+
@Since("1.2.0") @BeanProperty var treeStrategy: Strategy,
47+
@Since("1.2.0") @BeanProperty var loss: Loss,
4848
// Optional boosting parameters
49-
@BeanProperty var numIterations: Int = 100,
50-
@BeanProperty var learningRate: Double = 0.1,
51-
@BeanProperty var validationTol: Double = 1e-5) extends Serializable {
49+
@Since("1.2.0") @BeanProperty var numIterations: Int = 100,
50+
@Since("1.2.0") @BeanProperty var learningRate: Double = 0.1,
51+
@Since("1.4.0") @BeanProperty var validationTol: Double = 1e-5) extends Serializable {
5252

5353
/**
5454
* Check validity of parameters.

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/FeatureType.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import org.apache.spark.annotation.{Experimental, Since}
2626
@Since("1.0.0")
2727
@Experimental
2828
object FeatureType extends Enumeration {
29+
@Since("1.0.0")
2930
type FeatureType = Value
31+
@Since("1.0.0")
3032
val Continuous, Categorical = Value
3133
}

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/QuantileStrategy.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import org.apache.spark.annotation.{Experimental, Since}
2626
@Since("1.0.0")
2727
@Experimental
2828
object QuantileStrategy extends Enumeration {
29+
@Since("1.0.0")
2930
type QuantileStrategy = Value
31+
@Since("1.0.0")
3032
val Sort, MinMax, ApproxHist = Value
3133
}

mllib/src/main/scala/org/apache/spark/mllib/tree/configuration/Strategy.scala

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,20 +69,20 @@ import org.apache.spark.mllib.tree.configuration.QuantileStrategy._
6969
*/
7070
@Since("1.0.0")
7171
@Experimental
72-
class Strategy (
73-
@BeanProperty var algo: Algo,
74-
@BeanProperty var impurity: Impurity,
75-
@BeanProperty var maxDepth: Int,
76-
@BeanProperty var numClasses: Int = 2,
77-
@BeanProperty var maxBins: Int = 32,
78-
@BeanProperty var quantileCalculationStrategy: QuantileStrategy = Sort,
79-
@BeanProperty var categoricalFeaturesInfo: Map[Int, Int] = Map[Int, Int](),
80-
@BeanProperty var minInstancesPerNode: Int = 1,
81-
@BeanProperty var minInfoGain: Double = 0.0,
82-
@BeanProperty var maxMemoryInMB: Int = 256,
83-
@BeanProperty var subsamplingRate: Double = 1,
84-
@BeanProperty var useNodeIdCache: Boolean = false,
85-
@BeanProperty var checkpointInterval: Int = 10) extends Serializable {
72+
class Strategy @Since("1.3.0") (
73+
@Since("1.0.0") @BeanProperty var algo: Algo,
74+
@Since("1.0.0") @BeanProperty var impurity: Impurity,
75+
@Since("1.0.0") @BeanProperty var maxDepth: Int,
76+
@Since("1.2.0") @BeanProperty var numClasses: Int = 2,
77+
@Since("1.0.0") @BeanProperty var maxBins: Int = 32,
78+
@Since("1.0.0") @BeanProperty var quantileCalculationStrategy: QuantileStrategy = Sort,
79+
@Since("1.0.0") @BeanProperty var categoricalFeaturesInfo: Map[Int, Int] = Map[Int, Int](),
80+
@Since("1.2.0") @BeanProperty var minInstancesPerNode: Int = 1,
81+
@Since("1.2.0") @BeanProperty var minInfoGain: Double = 0.0,
82+
@Since("1.0.0") @BeanProperty var maxMemoryInMB: Int = 256,
83+
@Since("1.2.0") @BeanProperty var subsamplingRate: Double = 1,
84+
@Since("1.2.0") @BeanProperty var useNodeIdCache: Boolean = false,
85+
@Since("1.2.0") @BeanProperty var checkpointInterval: Int = 10) extends Serializable {
8686

8787
/**
8888
*/
@@ -206,6 +206,7 @@ object Strategy {
206206
}
207207

208208
@deprecated("Use Strategy.defaultStrategy instead.", "1.5.0")
209+
@Since("1.2.0")
209210
def defaultStategy(algo: Algo): Strategy = defaultStrategy(algo)
210211

211212
}

mllib/src/main/scala/org/apache/spark/mllib/tree/model/DecisionTreeModel.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ import org.apache.spark.util.Utils
4343
*/
4444
@Since("1.0.0")
4545
@Experimental
46-
class DecisionTreeModel(val topNode: Node, val algo: Algo) extends Serializable with Saveable {
46+
class DecisionTreeModel @Since("1.0.0") (
47+
@Since("1.0.0") val topNode: Node,
48+
@Since("1.0.0") val algo: Algo) extends Serializable with Saveable {
4749

4850
/**
4951
* Predict values for a single data point using the model trained.
@@ -110,6 +112,7 @@ class DecisionTreeModel(val topNode: Node, val algo: Algo) extends Serializable
110112
/**
111113
* Print the full model to a string.
112114
*/
115+
@Since("1.2.0")
113116
def toDebugString: String = {
114117
val header = toString + "\n"
115118
header + topNode.subtreeToString(2)

mllib/src/main/scala/org/apache/spark/mllib/tree/model/Node.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ import org.apache.spark.mllib.linalg.Vector
4141
*/
4242
@Since("1.0.0")
4343
@DeveloperApi
44-
class Node (
45-
val id: Int,
46-
var predict: Predict,
47-
var impurity: Double,
48-
var isLeaf: Boolean,
49-
var split: Option[Split],
50-
var leftNode: Option[Node],
51-
var rightNode: Option[Node],
52-
var stats: Option[InformationGainStats]) extends Serializable with Logging {
44+
class Node @Since("1.2.0") (
45+
@Since("1.0.0") val id: Int,
46+
@Since("1.0.0") var predict: Predict,
47+
@Since("1.2.0") var impurity: Double,
48+
@Since("1.0.0") var isLeaf: Boolean,
49+
@Since("1.0.0") var split: Option[Split],
50+
@Since("1.0.0") var leftNode: Option[Node],
51+
@Since("1.0.0") var rightNode: Option[Node],
52+
@Since("1.0.0") var stats: Option[InformationGainStats]) extends Serializable with Logging {
5353

5454
override def toString: String = {
5555
s"id = $id, isLeaf = $isLeaf, predict = $predict, impurity = $impurity, " +

mllib/src/main/scala/org/apache/spark/mllib/tree/model/Predict.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import org.apache.spark.annotation.{DeveloperApi, Since}
2626
*/
2727
@Since("1.2.0")
2828
@DeveloperApi
29-
class Predict(
30-
val predict: Double,
31-
val prob: Double = 0.0) extends Serializable {
29+
class Predict @Since("1.2.0") (
30+
@Since("1.2.0") val predict: Double,
31+
@Since("1.2.0") val prob: Double = 0.0) extends Serializable {
3232

3333
override def toString: String = s"$predict (prob = $prob)"
3434

0 commit comments

Comments
 (0)