Skip to content

Commit 678ec3a

Browse files
committed
Removed fixed random seeds from Word2Vec and ALS. Changed shared param HasSeed to have default based on hashCode of class name, instead of random number.
1 parent 3a60038 commit 678ec3a

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

mllib/src/main/scala/org/apache/spark/ml/feature/Word2Vec.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ private[feature] trait Word2VecBase extends Params
6868

6969
setDefault(stepSize -> 0.025)
7070
setDefault(maxIter -> 1)
71-
setDefault(seed -> 42L)
7271

7372
/**
7473
* Validate and transform the input schema.

mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private[shared] object SharedParamsCodeGen {
5353
ParamDesc[Int]("checkpointInterval", "checkpoint interval (>= 1)",
5454
isValid = "ParamValidators.gtEq(1)"),
5555
ParamDesc[Boolean]("fitIntercept", "whether to fit an intercept term", Some("true")),
56-
ParamDesc[Long]("seed", "random seed", Some("Utils.random.nextLong()")),
56+
ParamDesc[Long]("seed", "random seed", Some("this.getClass.getName.hashCode.toLong")),
5757
ParamDesc[Double]("elasticNetParam", "the ElasticNet mixing parameter, in range [0, 1]." +
5858
" For alpha = 0, the penalty is an L2 penalty. For alpha = 1, it is an L1 penalty.",
5959
isValid = "ParamValidators.inRange(0, 1)"),

mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private[ml] trait HasFitIntercept extends Params {
232232
}
233233

234234
/**
235-
* (private[ml]) Trait for shared param seed (default: Utils.random.nextLong()).
235+
* (private[ml]) Trait for shared param seed (default: this.getClass.getName.hashCode.toLong).
236236
*/
237237
private[ml] trait HasSeed extends Params {
238238

@@ -242,7 +242,7 @@ private[ml] trait HasSeed extends Params {
242242
*/
243243
final val seed: LongParam = new LongParam(this, "seed", "random seed")
244244

245-
setDefault(seed, Utils.random.nextLong())
245+
setDefault(seed, this.getClass.getName.hashCode.toLong)
246246

247247
/** @group getParam */
248248
final def getSeed: Long = $(seed)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ private[recommendation] trait ALSParams extends Params with HasMaxIter with HasR
148148

149149
setDefault(rank -> 10, maxIter -> 10, regParam -> 0.1, numUserBlocks -> 10, numItemBlocks -> 10,
150150
implicitPrefs -> false, alpha -> 1.0, userCol -> "user", itemCol -> "item",
151-
ratingCol -> "rating", nonnegative -> false, checkpointInterval -> 10, seed -> 0L)
151+
ratingCol -> "rating", nonnegative -> false, checkpointInterval -> 10)
152152

153153
/**
154154
* Validates and transforms the input schema.

0 commit comments

Comments
 (0)