You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@predictionio.apache.org by ta...@apache.org on 2017/05/10 12:04:23 UTC

incubator-predictionio-template-recommender git commit: add checkpoint parameters

Repository: incubator-predictionio-template-recommender
Updated Branches:
  refs/heads/develop 7a96540ad -> fab31fbfa


add checkpoint parameters


Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-recommender/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-recommender/commit/fab31fbf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-recommender/tree/fab31fbf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-recommender/diff/fab31fbf

Branch: refs/heads/develop
Commit: fab31fbfa2c407a014a5cc7b00e86935ff41e575
Parents: 7a96540
Author: Shinsuke Sugaya <sh...@yahoo.co.jp>
Authored: Wed May 10 20:33:30 2017 +0900
Committer: Naoki Takezoe <ta...@apache.org>
Committed: Wed May 10 20:33:30 2017 +0900

----------------------------------------------------------------------
 build.sbt                         |  4 ++--
 src/main/scala/ALSAlgorithm.scala | 36 +++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-recommender/blob/fab31fbf/build.sbt
----------------------------------------------------------------------
diff --git a/build.sbt b/build.sbt
index a7cb20c..a1f1914 100644
--- a/build.sbt
+++ b/build.sbt
@@ -2,5 +2,5 @@ name := "template-scala-parallel-recommendation"
 
 libraryDependencies ++= Seq(
   "org.apache.predictionio" %% "apache-predictionio-core" % "0.11.0-incubating" % "provided",
-  "org.apache.spark"        %% "spark-core"               % "1.3.0" % "provided",
-  "org.apache.spark"        %% "spark-mllib"              % "1.3.0" % "provided")
+  "org.apache.spark"        %% "spark-core"               % "1.4.0" % "provided",
+  "org.apache.spark"        %% "spark-mllib"              % "1.4.0" % "provided")

http://git-wip-us.apache.org/repos/asf/incubator-predictionio-template-recommender/blob/fab31fbf/src/main/scala/ALSAlgorithm.scala
----------------------------------------------------------------------
diff --git a/src/main/scala/ALSAlgorithm.scala b/src/main/scala/ALSAlgorithm.scala
index b53a9af..f99e525 100644
--- a/src/main/scala/ALSAlgorithm.scala
+++ b/src/main/scala/ALSAlgorithm.scala
@@ -27,7 +27,8 @@ class ALSAlgorithm(val ap: ALSAlgorithmParams)
   if (ap.numIterations > 30) {
     logger.warn(
       s"ALSAlgorithmParams.numIterations > 30, current: ${ap.numIterations}. " +
-      s"There is a chance of running to StackOverflowException. Lower this number to remedy it")
+      s"There is a chance of running to StackOverflowException." +
+      s"To remedy it, set lower numIterations or checkpoint parameters.")
   }
 
   def train(sc: SparkContext, data: PreparedData): ALSModel = {
@@ -48,24 +49,23 @@ class ALSAlgorithm(val ap: ALSAlgorithmParams)
     // seed for MLlib ALS
     val seed = ap.seed.getOrElse(System.nanoTime)
 
+    // Set checkpoint directory
+    // sc.setCheckpointDir("checkpoint")
+
     // If you only have one type of implicit event (Eg. "view" event only),
-    // replace ALS.train(...) with
-    //val m = ALS.trainImplicit(
-      //ratings = mllibRatings,
-      //rank = ap.rank,
-      //iterations = ap.numIterations,
-      //lambda = ap.lambda,
-      //blocks = -1,
-      //alpha = 1.0,
-      //seed = seed)
-
-    val m = ALS.train(
-      ratings = mllibRatings,
-      rank = ap.rank,
-      iterations = ap.numIterations,
-      lambda = ap.lambda,
-      blocks = -1,
-      seed = seed)
+    // set implicitPrefs to true
+    val implicitPrefs = false
+    val als = new ALS()
+    als.setUserBlocks(-1)
+    als.setProductBlocks(-1)
+    als.setRank(ap.rank)
+    als.setIterations(ap.numIterations)
+    als.setLambda(ap.lambda)
+    als.setImplicitPrefs(implicitPrefs)
+    als.setAlpha(1.0)
+    als.setSeed(seed)
+    als.setCheckpointInterval(10)
+    val m = als.run(mllibRatings)
 
     new ALSModel(
       rank = m.rank,