diff options
author | Joseph K. Bradley <joseph@databricks.com> | 2015-04-29 17:26:46 -0700 |
---|---|---|
committer | Xiangrui Meng <meng@databricks.com> | 2015-04-29 17:26:46 -0700 |
commit | 114bad606e7a17f980ea6c99e31c8ab0179fec2e (patch) | |
tree | f0a1a5f81f6f626412a9a526b72d0b6e5edf570c /examples/src/main | |
parent | 1fdfdb47b44315ff8ccb0ef92e56d3f2a070f1f1 (diff) | |
download | spark-114bad606e7a17f980ea6c99e31c8ab0179fec2e.tar.gz spark-114bad606e7a17f980ea6c99e31c8ab0179fec2e.tar.bz2 spark-114bad606e7a17f980ea6c99e31c8ab0179fec2e.zip |
[SPARK-7176] [ML] Add validation functionality to Param
Main change: Added isValid field to Param. Modified all usages to use isValid when relevant. Added helper methods in ParamValidate.
Also overrode Params.validate() in:
* CrossValidator + model
* Pipeline + model
I made a few updates for the elastic net patch:
* I changed "tol" to "convergenceTol"
* I added some documentation
This PR is Scala + Java only. Python will be in a follow-up PR.
CC: mengxr
Author: Joseph K. Bradley <joseph@databricks.com>
Closes #5740 from jkbradley/enforce-validate and squashes the following commits:
ad9c6c1 [Joseph K. Bradley] re-generated sharedParams after merging with current master
76415e8 [Joseph K. Bradley] reverted convergenceTol to tol
af62f4b [Joseph K. Bradley] Removed changes to SparkBuild, python linalg. Fixed test failures. Renamed ParamValidate to ParamValidators. Removed explicit type from ParamValidators calls where possible.
bb2665a [Joseph K. Bradley] merged with elastic net pr
ecda302 [Joseph K. Bradley] fix rat tests, plus add a little doc
6895dfc [Joseph K. Bradley] small cleanups
069ac6d [Joseph K. Bradley] many cleanups
928fb84 [Joseph K. Bradley] Maybe done
a910ac7 [Joseph K. Bradley] still workin
6d60e2e [Joseph K. Bradley] Still workin
b987319 [Joseph K. Bradley] Partly done with adding checks, but blocking on adding checking functionality to Param
dbc9fb2 [Joseph K. Bradley] merged with master. enforcing Params.validate
Diffstat (limited to 'examples/src/main')
-rw-r--r-- | examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java b/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java index eaf00d09f5..46377a99c4 100644 --- a/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java +++ b/examples/src/main/java/org/apache/spark/examples/ml/JavaDeveloperApiExample.java @@ -28,7 +28,6 @@ import org.apache.spark.ml.classification.Classifier; import org.apache.spark.ml.classification.ClassificationModel; import org.apache.spark.ml.param.IntParam; import org.apache.spark.ml.param.ParamMap; -import org.apache.spark.ml.param.Params; import org.apache.spark.ml.param.Params$; import org.apache.spark.mllib.linalg.BLAS; import org.apache.spark.mllib.linalg.Vector; @@ -100,11 +99,12 @@ public class JavaDeveloperApiExample { /** * Example of defining a type of {@link Classifier}. * - * NOTE: This is private since it is an example. In practice, you may not want it to be private. + * Note: Some IDEs (e.g., IntelliJ) will complain that this will not compile due to + * {@link org.apache.spark.ml.param.Params#set} using incompatible return types. + * However, this should still compile and run successfully. */ class MyJavaLogisticRegression - extends Classifier<Vector, MyJavaLogisticRegression, MyJavaLogisticRegressionModel> - implements Params { + extends Classifier<Vector, MyJavaLogisticRegression, MyJavaLogisticRegressionModel> { /** * Param for max number of iterations @@ -145,10 +145,12 @@ class MyJavaLogisticRegression /** * Example of defining a type of {@link ClassificationModel}. * - * NOTE: This is private since it is an example. In practice, you may not want it to be private. + * Note: Some IDEs (e.g., IntelliJ) will complain that this will not compile due to + * {@link org.apache.spark.ml.param.Params#set} using incompatible return types. + * However, this should still compile and run successfully. */ class MyJavaLogisticRegressionModel - extends ClassificationModel<Vector, MyJavaLogisticRegressionModel> implements Params { + extends ClassificationModel<Vector, MyJavaLogisticRegressionModel> { private MyJavaLogisticRegression parent_; public MyJavaLogisticRegression parent() { return parent_; } |