Last active
September 24, 2019 00:08
-
-
Save oneryalcin/122e312d9de413daca3a7afe4fa0bfbc to your computer and use it in GitHub Desktop.
13 Sparkify Cross Validation
This file contains 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
# Our Grid Search object allows us to define various hyperparameters to test our model | |
params = ParamGridBuilder()\ | |
.addGrid(classifier.maxDepth, [2, 5, 10])\ | |
.addGrid(classifier.featureSubsetStrategy, ['all', 'onethird', 'sqrt', 'log2'])\ | |
.build() | |
# Define the evaluator, this will measure teh success of model(s) | |
evaluator = binary_evaluator = BinaryClassificationEvaluator(labelCol='churned') | |
# CrossValidator will build pipeline, create models based on ParamGridBuilder, | |
# evalute against defined evaluator success and do cross validation using 5 folds | |
cv = CrossValidator(estimator=pipeline, | |
estimatorParamMaps=params, | |
evaluator=evaluator, | |
numFolds=5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment