Skip to content

Commit e8b0564

Browse files
BryanCutlersrowen
authored andcommitted
[SPARK-8400] [ML] Added check in ml.ALS for positive block size parameter setting
Added check for positive block size with a note that -1 for auto-configuring is not supported Author: Bryan Cutler <bjcutler@us.ibm.com> Closes #8363 from BryanCutler/ml.ALS-neg-blocksize-8400-1.3.
1 parent 3d2eaf0 commit e8b0564

File tree

1 file changed

+8
-2
lines changed
  • mllib/src/main/scala/org/apache/spark/ml/recommendation

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,16 @@ class ALS extends Estimator[ALSModel] with ALSParams {
234234
def setRank(value: Int): this.type = set(rank, value)
235235

236236
/** @group setParam */
237-
def setNumUserBlocks(value: Int): this.type = set(numUserBlocks, value)
237+
def setNumUserBlocks(value: Int): this.type = {
238+
require(value > 0, "Number of blocks must be > 0, auto-configuring with -1 is not supported.")
239+
set(numUserBlocks, value)
240+
}
238241

239242
/** @group setParam */
240-
def setNumItemBlocks(value: Int): this.type = set(numItemBlocks, value)
243+
def setNumItemBlocks(value: Int): this.type = {
244+
require(value > 0, "Number of blocks must be > 0, auto-configuring with -1 is not supported.")
245+
set(numItemBlocks, value)
246+
}
241247

242248
/** @group setParam */
243249
def setImplicitPrefs(value: Boolean): this.type = set(implicitPrefs, value)

0 commit comments

Comments
 (0)