Calmcode - scikit dummy: comparison

Comparison

1 2 3 4

Compare DummyClassifier with GridSeach

Let's run a dummy model in a gridsearch so we can compare with our original result.

pipe = Pipeline([
    ('scale', StandardScaler()),
    ('model', DummyClassifier())
])

grid = GridSearchCV(estimator=pipe,
                    param_grid={'model__strategy': ['stratified', 'most_frequent', 'uniform']},
                    cv=5,
                    scoring={'acc': make_scorer(accuracy_score)},
                    refit='acc',
                    return_train_score=True)

grid.fit(X, y)

To see the gridsearch results you can run;

pd.DataFrame(grid.cv_results_)[['param_model__strategy', 'mean_test_acc']]

Different strategies yield different results and inspecting these usually tells you something about the problem you're trying to solve.