Created
May 11, 2018 21:41
-
-
Save benoitdescamps/38b28c6430d7174ee902528fc10dc13a to your computer and use it in GitHub Desktop.
code snippets for Hyperparameters (part II): Random Search on Spark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.spark.ml.Pipeline | |
import org.apache.spark.ml.tuning.CrossValidatorModel | |
import org.apache.spark.ml.param.ParamMap | |
val pipeline: Pipeline = ... | |
val paramGrid: Array[ParamMap] = new ParamGridBuilder(). | |
addGrid(...). | |
addGrid(...). | |
build | |
val cv = new CrossValidator(). | |
setEstimator(pipeline). | |
setEvaluator(...). | |
setEstimatorParamMaps(paramGrid). | |
setNumFolds(...). | |
setParallelism(...) | |
val bestModel: CrossValidatorModel = cv.fit(training) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment