What is the difference between Python's functions cls.score and cls.cv_result_ give? : I have written a logistic regression code in Python (Anaconda 3.5.2 with sklearn 0.18.2). I am doing **gridsearchCV()** and **train_test_split**. My goal is to find final (average) accuracy over the '10' folds with standard error on the test data. Additionally, I am predicting *correctly predicted class labels*, creating a *confusion matrix* and preparing a *classification report* summary.

Please advise in the following:

(1) Is my code correct? Please check each part.

(2) I have tried two different sklearn functions, clf.score() and clf.cv_results_. I see that both give different results. Which one is correct? (I am not showing run results, but you may try it on any data).

    import numpy as np
    import pandas as pd
    from sklearn.linear_model import LogisticRegression
    from sklearn.model_selection import GridSearchCV, train_test_split
    from sklearn.metrics import classification_report,confusion_matrix
    from sklearn.pipeline import Pipeline
    
    # Load any n x m data and label column. No missing or NaN values.
    # I am skipping loading data part. One can load any data to test below code.

    sc = StandardScaler()
    lr = LogisticRegression()
    pipe = Pipeline(steps=[('sc', sc), ('lr', lr)])
    parameters = {'lr__C': [0.001, 0.01]}
    
    if __name__ == '__main__':
    
            clf = GridSearchCV(pipe, parameters, n_jobs=-1, cv=10, refit=True)
    
            X_train, X_test, y_train, y_test = train_test_split(Data, labels, random_state=0)
    
  
           # Train the classifier on data1's feature and target data
            clf.fit(X_train, y_train)

            print("Accuracy on training set: {:.2f}% \n".format((clf.score(X_train, y_train))*100))
            print("Accuracy on test set: {:.2f}%\n".format((clf.score(X_test, y_test))*100))
            print("Best Parameters: ")
            print(clf.best_params_)

         # Alternately using cv_results_
           print("Accuracy on training set: {:.2f}% \n", (clf.cv_results_['mean_train_score'])*100))
           print("Accuracy on test set: {:.2f}%\n", (clf.cv_results_['mean_test_score'])*100))

        # Predict class labels
        y_pred = clf.best_estimator_.predict(X_test)

        # Confusion Matrix
        class_names = ['Positive', 'Negative']
        confMatrix = confusion_matrix(y_test, y_pred)
        print(confMatrix)

        # Accuracy Report
        classificationReport = classification_report(labels, y_pred, target_names=class_names)
        print(classificationReport)


I will appreciate any advise.