aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala5
-rw-r--r--mllib/src/main/scala/org/apache/spark/ml/util/Instrumentation.scala7
2 files changed, 12 insertions, 0 deletions
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 6e4e6a6d85..cbcbfe8249 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)
}
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 869104e090..71a626647a 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 = {