Skip to content

Commit d6dbd4f

Browse files
committed
[SPARK-9864] [DOC] Replace since in scaladoc to Since annotation
1 parent dcfe0c5 commit d6dbd4f

File tree

68 files changed

+692
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+692
-862
lines changed

mllib/src/main/scala/org/apache/spark/mllib/classification/ClassificationModel.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package org.apache.spark.mllib.classification
1919

2020
import org.json4s.{DefaultFormats, JValue}
2121

22-
import org.apache.spark.annotation.Experimental
22+
import org.apache.spark.annotation.{Experimental, Since}
2323
import org.apache.spark.api.java.JavaRDD
2424
import org.apache.spark.mllib.linalg.Vector
2525
import org.apache.spark.rdd.RDD
@@ -36,25 +36,25 @@ trait ClassificationModel extends Serializable {
3636
*
3737
* @param testData RDD representing data points to be predicted
3838
* @return an RDD[Double] where each entry contains the corresponding prediction
39-
* @since 0.8.0
4039
*/
40+
@Since("0.8.0")
4141
def predict(testData: RDD[Vector]): RDD[Double]
4242

4343
/**
4444
* Predict values for a single data point using the model trained.
4545
*
4646
* @param testData array representing a single data point
4747
* @return predicted category from the trained model
48-
* @since 0.8.0
4948
*/
49+
@Since("0.8.0")
5050
def predict(testData: Vector): Double
5151

5252
/**
5353
* Predict values for examples stored in a JavaRDD.
5454
* @param testData JavaRDD representing data points to be predicted
5555
* @return a JavaRDD[java.lang.Double] where each entry contains the corresponding prediction
56-
* @since 0.8.0
5756
*/
57+
@Since("0.8.0")
5858
def predict(testData: JavaRDD[Vector]): JavaRDD[java.lang.Double] =
5959
predict(testData.rdd).toJavaRDD().asInstanceOf[JavaRDD[java.lang.Double]]
6060
}

mllib/src/main/scala/org/apache/spark/mllib/classification/LogisticRegression.scala

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.spark.mllib.classification
1919

2020
import org.apache.spark.SparkContext
21-
import org.apache.spark.annotation.Experimental
21+
import org.apache.spark.annotation.{Experimental, Since}
2222
import org.apache.spark.mllib.classification.impl.GLMClassificationModel
2323
import org.apache.spark.mllib.linalg.BLAS.dot
2424
import org.apache.spark.mllib.linalg.{DenseVector, Vector}
@@ -85,8 +85,8 @@ class LogisticRegressionModel (
8585
* in Binary Logistic Regression. An example with prediction score greater than or equal to
8686
* this threshold is identified as an positive, and negative otherwise. The default value is 0.5.
8787
* It is only used for binary classification.
88-
* @since 1.0.0
8988
*/
89+
@Since("1.0.0")
9090
@Experimental
9191
def setThreshold(threshold: Double): this.type = {
9292
this.threshold = Some(threshold)
@@ -97,17 +97,17 @@ class LogisticRegressionModel (
9797
* :: Experimental ::
9898
* Returns the threshold (if any) used for converting raw prediction scores into 0/1 predictions.
9999
* It is only used for binary classification.
100-
* @since 1.3.0
101100
*/
101+
@Since("1.3.0")
102102
@Experimental
103103
def getThreshold: Option[Double] = threshold
104104

105105
/**
106106
* :: Experimental ::
107107
* Clears the threshold so that `predict` will output raw prediction scores.
108108
* It is only used for binary classification.
109-
* @since 1.0.0
110109
*/
110+
@Since("1.0.0")
111111
@Experimental
112112
def clearThreshold(): this.type = {
113113
threshold = None
@@ -158,29 +158,23 @@ class LogisticRegressionModel (
158158
}
159159
}
160160

161-
/**
162-
* @since 1.3.0
163-
*/
161+
@Since("1.3.0")
164162
override def save(sc: SparkContext, path: String): Unit = {
165163
GLMClassificationModel.SaveLoadV1_0.save(sc, path, this.getClass.getName,
166164
numFeatures, numClasses, weights, intercept, threshold)
167165
}
168166

169167
override protected def formatVersion: String = "1.0"
170168

171-
/**
172-
* @since 1.4.0
173-
*/
169+
@Since("1.4.0")
174170
override def toString: String = {
175171
s"${super.toString}, numClasses = ${numClasses}, threshold = ${threshold.getOrElse("None")}"
176172
}
177173
}
178174

179175
object LogisticRegressionModel extends Loader[LogisticRegressionModel] {
180176

181-
/**
182-
* @since 1.3.0
183-
*/
177+
@Since("1.3.0")
184178
override def load(sc: SparkContext, path: String): LogisticRegressionModel = {
185179
val (loadedClassName, version, metadata) = Loader.loadMetadata(sc, path)
186180
// Hard-code class name string in case it changes in the future
@@ -261,8 +255,8 @@ object LogisticRegressionWithSGD {
261255
* @param miniBatchFraction Fraction of data to be used per iteration.
262256
* @param initialWeights Initial set of weights to be used. Array should be equal in size to
263257
* the number of features in the data.
264-
* @since 1.0.0
265258
*/
259+
@Since("1.0.0")
266260
def train(
267261
input: RDD[LabeledPoint],
268262
numIterations: Int,
@@ -284,8 +278,8 @@ object LogisticRegressionWithSGD {
284278
* @param stepSize Step size to be used for each iteration of gradient descent.
285279
286280
* @param miniBatchFraction Fraction of data to be used per iteration.
287-
* @since 1.0.0
288281
*/
282+
@Since("1.0.0")
289283
def train(
290284
input: RDD[LabeledPoint],
291285
numIterations: Int,
@@ -306,8 +300,8 @@ object LogisticRegressionWithSGD {
306300
307301
* @param numIterations Number of iterations of gradient descent to run.
308302
* @return a LogisticRegressionModel which has the weights and offset from training.
309-
* @since 1.0.0
310303
*/
304+
@Since("1.0.0")
311305
def train(
312306
input: RDD[LabeledPoint],
313307
numIterations: Int,
@@ -324,8 +318,8 @@ object LogisticRegressionWithSGD {
324318
* @param input RDD of (label, array of features) pairs.
325319
* @param numIterations Number of iterations of gradient descent to run.
326320
* @return a LogisticRegressionModel which has the weights and offset from training.
327-
* @since 1.0.0
328321
*/
322+
@Since("1.0.0")
329323
def train(
330324
input: RDD[LabeledPoint],
331325
numIterations: Int): LogisticRegressionModel = {
@@ -361,8 +355,8 @@ class LogisticRegressionWithLBFGS
361355
* Set the number of possible outcomes for k classes classification problem in
362356
* Multinomial Logistic Regression.
363357
* By default, it is binary logistic regression so k will be set to 2.
364-
* @since 1.3.0
365358
*/
359+
@Since("1.3.0")
366360
@Experimental
367361
def setNumClasses(numClasses: Int): this.type = {
368362
require(numClasses > 1)

mllib/src/main/scala/org/apache/spark/mllib/classification/NaiveBayes.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.json4s.JsonDSL._
2525
import org.json4s.jackson.JsonMethods._
2626

2727
import org.apache.spark.{Logging, SparkContext, SparkException}
28+
import org.apache.spark.annotation.Since
2829
import org.apache.spark.mllib.linalg.{BLAS, DenseMatrix, DenseVector, SparseVector, Vector}
2930
import org.apache.spark.mllib.regression.LabeledPoint
3031
import org.apache.spark.mllib.util.{Loader, Saveable}
@@ -444,8 +445,8 @@ object NaiveBayes {
444445
*
445446
* @param input RDD of `(label, array of features)` pairs. Every vector should be a frequency
446447
* vector or a count vector.
447-
* @since 0.9.0
448448
*/
449+
@Since("0.9.0")
449450
def train(input: RDD[LabeledPoint]): NaiveBayesModel = {
450451
new NaiveBayes().run(input)
451452
}
@@ -460,8 +461,8 @@ object NaiveBayes {
460461
* @param input RDD of `(label, array of features)` pairs. Every vector should be a frequency
461462
* vector or a count vector.
462463
* @param lambda The smoothing parameter
463-
* @since 0.9.0
464464
*/
465+
@Since("0.9.0")
465466
def train(input: RDD[LabeledPoint], lambda: Double): NaiveBayesModel = {
466467
new NaiveBayes(lambda, Multinomial).run(input)
467468
}
@@ -483,8 +484,8 @@ object NaiveBayes {
483484
*
484485
* @param modelType The type of NB model to fit from the enumeration NaiveBayesModels, can be
485486
* multinomial or bernoulli
486-
* @since 0.9.0
487487
*/
488+
@Since("0.9.0")
488489
def train(input: RDD[LabeledPoint], lambda: Double, modelType: String): NaiveBayesModel = {
489490
require(supportedModelTypes.contains(modelType),
490491
s"NaiveBayes was created with an unknown modelType: $modelType.")

mllib/src/main/scala/org/apache/spark/mllib/classification/SVM.scala

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.spark.mllib.classification
1919

2020
import org.apache.spark.SparkContext
21-
import org.apache.spark.annotation.Experimental
21+
import org.apache.spark.annotation.{Experimental, Since}
2222
import org.apache.spark.mllib.classification.impl.GLMClassificationModel
2323
import org.apache.spark.mllib.linalg.Vector
2424
import org.apache.spark.mllib.optimization._
@@ -46,8 +46,8 @@ class SVMModel (
4646
* Sets the threshold that separates positive predictions from negative predictions. An example
4747
* with prediction score greater than or equal to this threshold is identified as an positive,
4848
* and negative otherwise. The default value is 0.0.
49-
* @since 1.3.0
5049
*/
50+
@Since("1.3.0")
5151
@Experimental
5252
def setThreshold(threshold: Double): this.type = {
5353
this.threshold = Some(threshold)
@@ -57,16 +57,16 @@ class SVMModel (
5757
/**
5858
* :: Experimental ::
5959
* Returns the threshold (if any) used for converting raw prediction scores into 0/1 predictions.
60-
* @since 1.3.0
6160
*/
61+
@Since("1.3.0")
6262
@Experimental
6363
def getThreshold: Option[Double] = threshold
6464

6565
/**
6666
* :: Experimental ::
6767
* Clears the threshold so that `predict` will output raw prediction scores.
68-
* @since 1.0.0
6968
*/
69+
@Since("1.0.0")
7070
@Experimental
7171
def clearThreshold(): this.type = {
7272
threshold = None
@@ -84,29 +84,23 @@ class SVMModel (
8484
}
8585
}
8686

87-
/**
88-
* @since 1.3.0
89-
*/
87+
@Since("1.3.0")
9088
override def save(sc: SparkContext, path: String): Unit = {
9189
GLMClassificationModel.SaveLoadV1_0.save(sc, path, this.getClass.getName,
9290
numFeatures = weights.size, numClasses = 2, weights, intercept, threshold)
9391
}
9492

9593
override protected def formatVersion: String = "1.0"
9694

97-
/**
98-
* @since 1.4.0
99-
*/
95+
@Since("1.4.0")
10096
override def toString: String = {
10197
s"${super.toString}, numClasses = 2, threshold = ${threshold.getOrElse("None")}"
10298
}
10399
}
104100

105101
object SVMModel extends Loader[SVMModel] {
106102

107-
/**
108-
* @since 1.3.0
109-
*/
103+
@Since("1.3.0")
110104
override def load(sc: SparkContext, path: String): SVMModel = {
111105
val (loadedClassName, version, metadata) = Loader.loadMetadata(sc, path)
112106
// Hard-code class name string in case it changes in the future
@@ -185,8 +179,8 @@ object SVMWithSGD {
185179
* @param miniBatchFraction Fraction of data to be used per iteration.
186180
* @param initialWeights Initial set of weights to be used. Array should be equal in size to
187181
* the number of features in the data.
188-
* @since 0.8.0
189182
*/
183+
@Since("0.8.0")
190184
def train(
191185
input: RDD[LabeledPoint],
192186
numIterations: Int,
@@ -209,8 +203,8 @@ object SVMWithSGD {
209203
* @param stepSize Step size to be used for each iteration of gradient descent.
210204
* @param regParam Regularization parameter.
211205
* @param miniBatchFraction Fraction of data to be used per iteration.
212-
* @since 0.8.0
213206
*/
207+
@Since("0.8.0")
214208
def train(
215209
input: RDD[LabeledPoint],
216210
numIterations: Int,
@@ -231,8 +225,8 @@ object SVMWithSGD {
231225
* @param regParam Regularization parameter.
232226
* @param numIterations Number of iterations of gradient descent to run.
233227
* @return a SVMModel which has the weights and offset from training.
234-
* @since 0.8.0
235228
*/
229+
@Since("0.8.0")
236230
def train(
237231
input: RDD[LabeledPoint],
238232
numIterations: Int,
@@ -250,8 +244,8 @@ object SVMWithSGD {
250244
* @param input RDD of (label, array of features) pairs.
251245
* @param numIterations Number of iterations of gradient descent to run.
252246
* @return a SVMModel which has the weights and offset from training.
253-
* @since 0.8.0
254247
*/
248+
@Since("0.8.0")
255249
def train(input: RDD[LabeledPoint], numIterations: Int): SVMModel = {
256250
train(input, numIterations, 1.0, 0.01, 1.0)
257251
}

0 commit comments

Comments
 (0)