What is the significance of scikit-learn GridSearchCV best_score_
<p>I can see the answer at <a href="http://stackoverflow.com/questions/24096146/how-is-scikit-learn-gridsearchcv-best-score-calculated">How is scikit-learn GridSearchCV best_score_ calculated?</a> for the what this score means.</p>

<p>I am working with scikit learn example for decision tree and trying various values for scoring parameter.</p>

<pre><code>if __name__ == '__main__':
   df = pd.read_csv('/Users/tcssig/Downloads/ad-dataset/ad.data', header=None)
   explanatory_variable_columns = set(df.columns.values)
   response_variable_column = df[len(df.columns.values)-1]
   # The last column describes the targets
   explanatory_variable_columns.remove(len(df.columns.values)-1)
   y = [1 if e == 'ad.' else 0 for e in response_variable_column]
   X = df[list(explanatory_variable_columns)]
   X.replace(to_replace=' *\?', value=-1, regex=True, inplace=True)
   X_train, X_test, y_train, y_test = train_test_split(X, y)
   pipeline = Pipeline([('clf', DecisionTreeClassifier(criterion='entropy'))])
   parameters = {'clf__max_depth': (150, 155, 160), 'clf__min_samples_split': (1, 2, 3), 'clf__min_samples_leaf': (1, 2, 3)}
   grid_search = GridSearchCV(pipeline, parameters, n_jobs=-1,verbose=1, scoring='accuracy')
   grid_search.fit(X_train, y_train)
   print ('Best score: %0.3f' % grid_search.best_score_)
   best_parameters = grid_search.best_estimator_.get_params()
   for param_name in sorted(parameters.keys()):
        print ('\t%s: %r' % (param_name, best_parameters[param_name]))
   predictions = grid_search.predict(X_test)
   print (classification_report(y_test, predictions))
</code></pre>

<p>Every time I get a diff value for  <code>best_score_</code>, ranging from <code>0.92</code> to <code>0.96</code>.</p>

<p>Should this score determine the Scoring parameter value that I should finally use.
Also on scikit learn website, I see that accuracy value should not be used in case of imbalanced classification.</p>

<p>The best_score_ value is different every time because you have not passed a fixed value for random_state in your DecisionTreeClassifier. You can do the following in order to get the same value every time you run your code on any machine.</p>

<pre><code>random_seed = 77   ##It can be any value of your choice
pipeline = Pipeline([('clf', DecisionTreeClassifier(criterion='entropy', random_state = random_seed))])
</code></pre>

<p>I hope this will be useful.</p>

python pandas scikit-learn grid-search