[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
This commit is contained in:
ludatabricks 2018-06-04 11:09:41 -07:00 committed by Xiangrui Meng
parent 1768d376f9
commit f1139fc742

View File

@ -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
}
}