From f1139fc742dad551057311dabe77854b7e75f709 Mon Sep 17 00:00:00 2001 From: ludatabricks <38018689+ludatabricks@users.noreply.github.com> Date: Mon, 4 Jun 2018 11:09:41 -0700 Subject: [PATCH] [ML-3753] Log "value" instead of "Some(value)" for ML params in results (#145) Change the function MLParams.toMap so it will not output a option value in the map. We will not get option value in the params in the output result. * change the "option" number to direct number * update based on the comments --- .../scala/com/databricks/spark/sql/perf/results.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/scala/com/databricks/spark/sql/perf/results.scala b/src/main/scala/com/databricks/spark/sql/perf/results.scala index 209a732..87f0a28 100644 --- a/src/main/scala/com/databricks/spark/sql/perf/results.scala +++ b/src/main/scala/com/databricks/spark/sql/perf/results.scala @@ -148,9 +148,13 @@ class MLParams( * were defined (i.e., not equal to None) are included in the map. */ def toMap: Map[String, String] = { + // Only outputs params that have values val allParams = ReflectionUtils.getConstructorArgs(this) - allParams.map { case (key: String, value: Any) => - key -> value.toString + allParams.flatMap { + case (key: String, Some(value: Any)) => + Some(key -> value.toString) + case _ => + None } } @@ -236,4 +240,4 @@ case class MLMetric( object MLMetric { val Invalid = MLMetric("Invalid", 0.0, false) -} \ No newline at end of file +}