Repository: spark Updated Branches: refs/heads/master 6d5aeaae2 -> b6fa7e593
[SPARK-14571][ML] Log instrumentation in ALS ## What changes were proposed in this pull request? Add log instrumentation for parameters: rank, numUserBlocks, numItemBlocks, implicitPrefs, alpha, userCol, itemCol, ratingCol, predictionCol, maxIter, regParam, nonnegative, checkpointInterval, seed Add log instrumentation for numUserFeatures and numItemFeatures ## How was this patch tested? Manual test: Set breakpoint in intellij and run def testALS(). Single step debugging and check the log method is called. Author: [email protected] <[email protected]> Closes #12560 from wangmiao1981/log. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b6fa7e59 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b6fa7e59 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b6fa7e59 Branch: refs/heads/master Commit: b6fa7e5934ca5d1c3c757629833396b810894067 Parents: 6d5aeaa Author: [email protected] <[email protected]> Authored: Fri Apr 29 16:18:25 2016 +0200 Committer: Nick Pentreath <[email protected]> Committed: Fri Apr 29 16:18:25 2016 +0200 ---------------------------------------------------------------------- .../main/scala/org/apache/spark/ml/recommendation/ALS.scala | 5 +++++ .../main/scala/org/apache/spark/ml/util/Instrumentation.scala | 7 +++++++ 2 files changed, 12 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/b6fa7e59/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala ---------------------------------------------------------------------- diff --git a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala index 6e4e6a6..cbcbfe8 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala @@ -395,6 +395,10 @@ class ALS(@Since("1.4.0") override val uid: String) extends Estimator[ALSModel] .map { row => Rating(row.getInt(0), row.getInt(1), row.getFloat(2)) } + val instrLog = Instrumentation.create(this, ratings) + instrLog.logParams(rank, numUserBlocks, numItemBlocks, implicitPrefs, alpha, + userCol, itemCol, ratingCol, predictionCol, maxIter, + regParam, nonnegative, checkpointInterval, seed) val (userFactors, itemFactors) = ALS.train(ratings, rank = $(rank), numUserBlocks = $(numUserBlocks), numItemBlocks = $(numItemBlocks), maxIter = $(maxIter), regParam = $(regParam), implicitPrefs = $(implicitPrefs), @@ -403,6 +407,7 @@ class ALS(@Since("1.4.0") override val uid: String) extends Estimator[ALSModel] val userDF = userFactors.toDF("id", "features") val itemDF = itemFactors.toDF("id", "features") val model = new ALSModel(uid, $(rank), userDF, itemDF).setParent(this) + instrLog.logSuccess(model) copyValues(model) } http://git-wip-us.apache.org/repos/asf/spark/blob/b6fa7e59/mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala ---------------------------------------------------------------------- diff --git a/mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala b/mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala index 869104e..71a6266 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala @@ -85,6 +85,13 @@ private[spark] class Instrumentation[E <: Estimator[_]] private ( } /** + * Logs the value with customized name field. + */ + def logNamedValue(name: String, num: Long): Unit = { + log(compact(render(name -> num))) + } + + /** * Logs the successful completion of the training session and the value of the learned model. */ def logSuccess(model: Model[_]): Unit = { --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
