diff options
author | hqzizania <hqzizania@gmail.com> | 2016-08-22 17:09:08 -0700 |
---|---|---|
committer | Yanbo Liang <ybliang8@gmail.com> | 2016-08-22 17:09:08 -0700 |
commit | 37f0ab70d25802b609317bc93421d2fe3ee9db6e (patch) | |
tree | 132bb6e7eb9f29155eb2debb43e77ecfca58c383 /mllib/src/main | |
parent | 6d93f9e0236aa61e39a1abfb0f7f7c558fb7d5d5 (diff) | |
download | spark-37f0ab70d25802b609317bc93421d2fe3ee9db6e.tar.gz spark-37f0ab70d25802b609317bc93421d2fe3ee9db6e.tar.bz2 spark-37f0ab70d25802b609317bc93421d2fe3ee9db6e.zip |
[SPARK-17090][FOLLOW-UP][ML] Add expert param support to SharedParamsCodeGen
## What changes were proposed in this pull request?
Add expert param support to SharedParamsCodeGen where aggregationDepth a expert param is added.
Author: hqzizania <hqzizania@gmail.com>
Closes #14738 from hqzizania/SPARK-17090-minor.
Diffstat (limited to 'mllib/src/main')
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala | 14 | ||||
-rw-r--r-- | mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala | 4 |
2 files changed, 12 insertions, 6 deletions
diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala b/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala index 0f48a16a42..480b03d0f3 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/param/shared/SharedParamsCodeGen.scala @@ -80,7 +80,7 @@ private[shared] object SharedParamsCodeGen { ParamDesc[String]("solver", "the solver algorithm for optimization. If this is not set or " + "empty, default value is 'auto'", Some("\"auto\"")), ParamDesc[Int]("aggregationDepth", "suggested depth for treeAggregate (>= 2)", Some("2"), - isValid = "ParamValidators.gtEq(2)")) + isValid = "ParamValidators.gtEq(2)", isExpertParam = true)) val code = genSharedParams(params) val file = "src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala" @@ -95,7 +95,8 @@ private[shared] object SharedParamsCodeGen { doc: String, defaultValueStr: Option[String] = None, isValid: String = "", - finalMethods: Boolean = true) { + finalMethods: Boolean = true, + isExpertParam: Boolean = false) { require(name.matches("[a-z][a-zA-Z0-9]*"), s"Param name $name is invalid.") require(doc.nonEmpty) // TODO: more rigorous on doc @@ -153,6 +154,11 @@ private[shared] object SharedParamsCodeGen { } else { "" } + val groupStr = if (param.isExpertParam) { + Array("expertParam", "expertGetParam") + } else { + Array("param", "getParam") + } val methodStr = if (param.finalMethods) { "final def" } else { @@ -167,11 +173,11 @@ private[shared] object SharedParamsCodeGen { | | /** | * Param for $doc. - | * @group param + | * @group ${groupStr(0)} | */ | final val $name: $Param = new $Param(this, "$name", "$doc"$isValid) |$setDefault - | /** @group getParam */ + | /** @group ${groupStr(1)} */ | $methodStr get$Name: $T = $$($name) |} |""".stripMargin diff --git a/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala b/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala index 6803772c63..9125d9e19b 100644 --- a/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala +++ b/mllib/src/main/scala/org/apache/spark/ml/param/shared/sharedParams.scala @@ -397,13 +397,13 @@ private[ml] trait HasAggregationDepth extends Params { /** * Param for suggested depth for treeAggregate (>= 2). - * @group param + * @group expertParam */ final val aggregationDepth: IntParam = new IntParam(this, "aggregationDepth", "suggested depth for treeAggregate (>= 2)", ParamValidators.gtEq(2)) setDefault(aggregationDepth, 2) - /** @group getParam */ + /** @group expertGetParam */ final def getAggregationDepth: Int = $(aggregationDepth) } // scalastyle:on |