Skip to content

Instantly share code, notes, and snippets.

@qharlie
Created February 24, 2017 17:01
Show Gist options
  • Save qharlie/734266a7660e02b4197a88107a0b76cb to your computer and use it in GitHub Desktop.
Save qharlie/734266a7660e02b4197a88107a0b76cb to your computer and use it in GitHub Desktop.
for score in scores:
sss = StratifiedShuffleSplit()
search = GridSearchCV(pipe, param_grid, cv=sss, scoring="recall", n_jobs=-1)
search.fit(features, labels)
print("BEST SCORE = " + str(search.score(features_test,labels_test)))
print("BEST PARAMS = " + str(search.best_params_)) # the parameter combination that together got the best f1 score
print("BEST ESTIMATOR = " + str(search.best_estimator_))
'''BEST SCORE = 1.0
BEST PARAMS = {'decisiontreeclassifier__presort': True, 'pca__n_components': 6, 'selectatmostkbest__k': 3, 'decisiontreeclassifier__criterion': 'gini', 'decisiontreeclassifier__splitter': 'best'}
BEST ESTIMATOR = Pipeline(steps=[('standardscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('pca', PCA(copy=True, iterated_power='auto', n_components=6, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)), ('selectatmostkbest', SelectAtMostKBest(k=3, score_func=<function f_classif at 0x7f22a89...lit=2, min_weight_fraction_leaf=0.0,
presort=True, random_state=None, splitter='best'))])
BEST SCORE = 1.0
BEST PARAMS = {'decisiontreeclassifier__presort': False, 'pca__n_components': 4, 'selectatmostkbest__k': 2, 'decisiontreeclassifier__criterion': 'gini', 'decisiontreeclassifier__splitter': 'random'}
BEST ESTIMATOR = Pipeline(steps=[('standardscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('pca', PCA(copy=True, iterated_power='auto', n_components=4, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)), ('selectatmostkbest', SelectAtMostKBest(k=2, score_func=<function f_classif at 0x7f22a89...=2, min_weight_fraction_leaf=0.0,
presort=False, random_state=None, splitter='random'))])
BEST SCORE = 1.0
BEST PARAMS = {'decisiontreeclassifier__presort': False, 'pca__n_components': 6, 'selectatmostkbest__k': 4, 'decisiontreeclassifier__criterion': 'gini', 'decisiontreeclassifier__splitter': 'best'}
BEST ESTIMATOR = Pipeline(steps=[('standardscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('pca', PCA(copy=True, iterated_power='auto', n_components=6, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)), ('selectatmostkbest', SelectAtMostKBest(k=4, score_func=<function f_classif at 0x7f22a89...it=2, min_weight_fraction_leaf=0.0,
presort=False, random_state=None, splitter='best'))])
BEST SCORE = 1.0
BEST PARAMS = {'decisiontreeclassifier__presort': True, 'pca__n_components': 5, 'selectatmostkbest__k': 3, 'decisiontreeclassifier__criterion': 'gini', 'decisiontreeclassifier__splitter': 'best'}
BEST ESTIMATOR = Pipeline(steps=[('standardscaler', StandardScaler(copy=True, with_mean=True, with_std=True)), ('pca', PCA(copy=True, iterated_power='auto', n_components=5, random_state=None,
svd_solver='auto', tol=0.0, whiten=False)), ('selectatmostkbest', SelectAtMostKBest(k=3, score_func=<function f_classif at 0x7f22a89...lit=2, min_weight_fraction_leaf=0.0,
presort=True, random_state=None, splitter='best'))])'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment