Github user jkbradley commented on a diff in the pull request:
https://github.com/apache/spark/pull/19208#discussion_r149227862
--- Diff:
mllib/src/main/scala/org/apache/spark/ml/tuning/CrossValidator.scala ---
@@ -323,39 +338,40 @@ object CrossValidatorModel extends
MLReadable[CrossValidatorModel] {
@Since("1.6.0")
override def load(path: String): CrossValidatorModel = super.load(path)
- private[CrossValidatorModel]
+ /**
+ * Writer for CrossValidatorModel.
+ * @param instance CrossValidatorModel instance used to construct the
writer
+ *
+ * Options:
+ * CrossValidatorModelWriter support an option "persistSubModels",
available value is
+ * "true" or "false". If you set collectSubModels param before fitting,
and then you can set
+ * the option "persistSubModels" to be "true" and the submodels will be
persisted.
+ * The default value of "persistSubModels" will be "true", if you set
collectSubModels
+ * param before fitting, but if you do not set collectSubModels param
before fitting, setting
+ * "persistSubModels" will cause exception.
+ */
+ @Since("2.3.0")
class CrossValidatorModelWriter(instance: CrossValidatorModel) extends
MLWriter {
ValidatorParams.validateParams(instance)
- protected var shouldPersistSubModels: Boolean = if
(instance.hasSubModels) true else false
-
- /**
- * Extra options for CrossValidatorModelWriter, current support
"persistSubModels".
- * if sub models exsit, the default value for option
"persistSubModels" is "true".
- */
- @Since("2.3.0")
- override def option(key: String, value: String): this.type = {
- key.toLowerCase(Locale.ROOT) match {
- case "persistsubmodels" => shouldPersistSubModels = value.toBoolean
- case _ => throw new IllegalArgumentException(
- s"Illegal option ${key} for CrossValidatorModelWriter")
- }
- this
- }
-
override protected def saveImpl(path: String): Unit = {
+ val persistSubModels = optionMap.getOrElse("persistsubmodels",
--- End diff --
Please update this so that, when the valid is not convertible to a Boolean,
the user sees an error message which states the invalid value and the possible
valid values.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]