GridSearchCV.best_score_意味着当得分设置为'准确度'和CV时

Tak*_*aka 1 python pandas scikit-learn cross-validation grid-search

我正在尝试找到应用于众所周知的威斯康星癌症数据集(569个样本,31个特征+目标)的乳腺癌样本分类的最佳模型神经网络模型.我正在使用sklearn 0.18.1.到目前为止我还没有使用Normalization.当我解决这个问题时,我会添加它.

# some init code omitted
X_train, X_test, y_train, y_test = train_test_split(X, y)
Run Code Online (Sandbox Code Playgroud)

为GridSearchCV定义params NN params

tuned_params = [{'solver': ['sgd'], 'learning_rate': ['constant'], "learning_rate_init" : [0.001, 0.01, 0.05, 0.1]},
                {"learning_rate_init" : [0.001, 0.01, 0.05, 0.1]}]
Run Code Online (Sandbox Code Playgroud)

CV方法和模型

cv_method = KFold(n_splits=4, shuffle=True)
model = MLPClassifier()
Run Code Online (Sandbox Code Playgroud)

应用网格

grid = GridSearchCV(estimator=model, param_grid=tuned_params, cv=cv_method, scoring='accuracy')
grid.fit(X_train, y_train)
y_pred = grid.predict(X_test)
Run Code Online (Sandbox Code Playgroud)

如果我跑:

print(grid.best_score_)
print(accuracy_score(y_test, y_pred))
Run Code Online (Sandbox Code Playgroud)

结果为0.7464788732390.902097902098

根据文档"best_score_:float,best_estimator得分左侧数据".我认为在运行8种不同配置的那些中获得的最佳准确度是在tuned_pa​​rams中指定的次数,由KFold指定的次数,在左边的数据中由KFold指定.我对吗?

还有一个问题.有没有一种方法可以找到在train_test_split中使用的最佳测试数据大小,默认为0.25?

非常感谢

参考

Viv*_*mar 6

grid.best_score_是您在指定的参数的单个组合的所有cv折叠的平均值tuned_params.

要访问有关网格搜索过程的其他相关详细信息,您可以查看该grid.cv_results_属性.

GridSearchCV文档:

cv_results_:numpy(蒙面)ndarrays的字典

A dict with keys as column headers and values as columns, 
that can be imported into a pandas DataFrame
Run Code Online (Sandbox Code Playgroud)

它包含"split0_test_score","split1_test_score","mean_test_score","std_test_score","rank_test_score","split0_train_score","split1_train_score","mean_train_score"等键,提供有关整个执行的其他信息.