Skip to content

Commit 233d6ce

Browse files
Wenpeisrowen
authored andcommitted
[SPARK-10264][DOCUMENTATION] Added @SInCE to ml.recomendation
I create new pr since original pr long time no update. Please help to review. srowen Author: Tommy YU <[email protected]> Closes #10756 from Wenpei/add_since_to_recomm.
1 parent bc36b0f commit 233d6ce

File tree

1 file changed

+30
-3
lines changed
  • mllib/src/main/scala/org/apache/spark/ml/recommendation

1 file changed

+30
-3
lines changed

mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,27 @@ private[recommendation] trait ALSParams extends ALSModelParams with HasMaxIter w
180180
* @param itemFactors a DataFrame that stores item factors in two columns: `id` and `features`
181181
*/
182182
@Experimental
183+
@Since("1.3.0")
183184
class ALSModel private[ml] (
184-
override val uid: String,
185-
val rank: Int,
185+
@Since("1.4.0") override val uid: String,
186+
@Since("1.4.0") val rank: Int,
186187
@transient val userFactors: DataFrame,
187188
@transient val itemFactors: DataFrame)
188189
extends Model[ALSModel] with ALSModelParams with MLWritable {
189190

190191
/** @group setParam */
192+
@Since("1.4.0")
191193
def setUserCol(value: String): this.type = set(userCol, value)
192194

193195
/** @group setParam */
196+
@Since("1.4.0")
194197
def setItemCol(value: String): this.type = set(itemCol, value)
195198

196199
/** @group setParam */
200+
@Since("1.3.0")
197201
def setPredictionCol(value: String): this.type = set(predictionCol, value)
198202

203+
@Since("1.3.0")
199204
override def transform(dataset: DataFrame): DataFrame = {
200205
// Register a UDF for DataFrame, and then
201206
// create a new column named map(predictionCol) by running the predict UDF.
@@ -213,13 +218,15 @@ class ALSModel private[ml] (
213218
predict(userFactors("features"), itemFactors("features")).as($(predictionCol)))
214219
}
215220

221+
@Since("1.3.0")
216222
override def transformSchema(schema: StructType): StructType = {
217223
validateParams()
218224
SchemaUtils.checkColumnType(schema, $(userCol), IntegerType)
219225
SchemaUtils.checkColumnType(schema, $(itemCol), IntegerType)
220226
SchemaUtils.appendColumn(schema, $(predictionCol), FloatType)
221227
}
222228

229+
@Since("1.5.0")
223230
override def copy(extra: ParamMap): ALSModel = {
224231
val copied = new ALSModel(uid, rank, userFactors, itemFactors)
225232
copyValues(copied, extra).setParent(parent)
@@ -303,65 +310,83 @@ object ALSModel extends MLReadable[ALSModel] {
303310
* preferences rather than explicit ratings given to items.
304311
*/
305312
@Experimental
306-
class ALS(override val uid: String) extends Estimator[ALSModel] with ALSParams
313+
@Since("1.3.0")
314+
class ALS(@Since("1.4.0") override val uid: String) extends Estimator[ALSModel] with ALSParams
307315
with DefaultParamsWritable {
308316

309317
import org.apache.spark.ml.recommendation.ALS.Rating
310318

319+
@Since("1.4.0")
311320
def this() = this(Identifiable.randomUID("als"))
312321

313322
/** @group setParam */
323+
@Since("1.3.0")
314324
def setRank(value: Int): this.type = set(rank, value)
315325

316326
/** @group setParam */
327+
@Since("1.3.0")
317328
def setNumUserBlocks(value: Int): this.type = set(numUserBlocks, value)
318329

319330
/** @group setParam */
331+
@Since("1.3.0")
320332
def setNumItemBlocks(value: Int): this.type = set(numItemBlocks, value)
321333

322334
/** @group setParam */
335+
@Since("1.3.0")
323336
def setImplicitPrefs(value: Boolean): this.type = set(implicitPrefs, value)
324337

325338
/** @group setParam */
339+
@Since("1.3.0")
326340
def setAlpha(value: Double): this.type = set(alpha, value)
327341

328342
/** @group setParam */
343+
@Since("1.3.0")
329344
def setUserCol(value: String): this.type = set(userCol, value)
330345

331346
/** @group setParam */
347+
@Since("1.3.0")
332348
def setItemCol(value: String): this.type = set(itemCol, value)
333349

334350
/** @group setParam */
351+
@Since("1.3.0")
335352
def setRatingCol(value: String): this.type = set(ratingCol, value)
336353

337354
/** @group setParam */
355+
@Since("1.3.0")
338356
def setPredictionCol(value: String): this.type = set(predictionCol, value)
339357

340358
/** @group setParam */
359+
@Since("1.3.0")
341360
def setMaxIter(value: Int): this.type = set(maxIter, value)
342361

343362
/** @group setParam */
363+
@Since("1.3.0")
344364
def setRegParam(value: Double): this.type = set(regParam, value)
345365

346366
/** @group setParam */
367+
@Since("1.3.0")
347368
def setNonnegative(value: Boolean): this.type = set(nonnegative, value)
348369

349370
/** @group setParam */
371+
@Since("1.4.0")
350372
def setCheckpointInterval(value: Int): this.type = set(checkpointInterval, value)
351373

352374
/** @group setParam */
375+
@Since("1.3.0")
353376
def setSeed(value: Long): this.type = set(seed, value)
354377

355378
/**
356379
* Sets both numUserBlocks and numItemBlocks to the specific value.
357380
* @group setParam
358381
*/
382+
@Since("1.3.0")
359383
def setNumBlocks(value: Int): this.type = {
360384
setNumUserBlocks(value)
361385
setNumItemBlocks(value)
362386
this
363387
}
364388

389+
@Since("1.3.0")
365390
override def fit(dataset: DataFrame): ALSModel = {
366391
import dataset.sqlContext.implicits._
367392
val r = if ($(ratingCol) != "") col($(ratingCol)).cast(FloatType) else lit(1.0f)
@@ -381,10 +406,12 @@ class ALS(override val uid: String) extends Estimator[ALSModel] with ALSParams
381406
copyValues(model)
382407
}
383408

409+
@Since("1.3.0")
384410
override def transformSchema(schema: StructType): StructType = {
385411
validateAndTransformSchema(schema)
386412
}
387413

414+
@Since("1.5.0")
388415
override def copy(extra: ParamMap): ALS = defaultCopy(extra)
389416
}
390417

0 commit comments

Comments
 (0)