Skip to content

Commit

Permalink
fixed seed
Browse files Browse the repository at this point in the history
  • Loading branch information
brkyvz committed May 8, 2015
1 parent 7f6d964 commit 0bd66b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Expand Up @@ -147,7 +147,7 @@ private[recommendation] trait ALSParams extends Params with HasMaxIter with HasR

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

/**
* Validates and transforms the input schema.
Expand Down
13 changes: 6 additions & 7 deletions python/pyspark/ml/recommendation.py
Expand Up @@ -80,11 +80,11 @@ class ALS(JavaEstimator, HasCheckpointInterval, HasMaxIter, HasPredictionCol, Ha

@keyword_only
def __init__(self, rank=10, maxIter=10, regParam=0.1, numUserBlocks=10, numItemBlocks=10,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=42L,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=0,
ratingCol="rating", nonnegative=False, checkpointInterval=10):
"""
__init__(self, rank=10, maxIter=10, regParam=0.1, numUserBlocks=10, numItemBlocks=10,
implicitPrefs=false, alpha=1.0, userCol="user", itemCol="item", seed=42L,
implicitPrefs=false, alpha=1.0, userCol="user", itemCol="item", seed=0,
ratingCol="rating", nonnegative=false, checkpointInterval=10)
"""
super(ALS, self).__init__()
Expand All @@ -99,18 +99,18 @@ def __init__(self, rank=10, maxIter=10, regParam=0.1, numUserBlocks=10, numItemB
self.nonnegative = Param(self, "nonnegative",
"whether to use nonnegative constraint for least squares")
self._setDefault(rank=10, maxIter=10, regParam=0.1, numUserBlocks=10, numItemBlocks=10,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=42,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=0,
ratingCol="rating", nonnegative=False, checkpointInterval=10)
kwargs = self.__init__._input_kwargs
self.setParams(**kwargs)

@keyword_only
def setParams(self, rank=10, maxIter=10, regParam=0.1, numUserBlocks=10, numItemBlocks=10,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=42,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=0,
ratingCol="rating", nonnegative=False, checkpointInterval=10):
"""
setParams(self, rank=10, maxIter=10, regParam=0.1, numUserBlocks=10, numItemBlocks=10,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=42,
implicitPrefs=False, alpha=1.0, userCol="user", itemCol="item", seed=0,
ratingCol="rating", nonnegative=False, checkpointInterval=10)
Sets params for ALS.
"""
Expand Down Expand Up @@ -166,7 +166,6 @@ def setNumBlocks(self, value):
self.paramMap[self.numUserBlocks] = value
self.paramMap[self.numItemBlocks] = value


def setImplicitPrefs(self, value):
"""
Sets the value of :py:attr:`implicitPrefs`.
Expand Down Expand Up @@ -264,7 +263,7 @@ class ALSModel(JavaModel):
globs['sc'] = sc
globs['sqlContext'] = sqlContext
globs['df'] = sqlContext.createDataFrame([(0, 0, 4.0), (0, 1, 2.0), (1, 1, 3.0), (1, 2, 4.0),
(2, 1, 1.0), (2, 2, 5.0)], ["user", "item", "rating"])
(2, 1, 1.0), (2, 2, 5.0)], ["user", "item", "rating"])
(failure_count, test_count) = doctest.testmod(globs=globs, optionflags=doctest.ELLIPSIS)
sc.stop()
if failure_count:
Expand Down

0 comments on commit 0bd66b1

Please sign in to comment.