Python 3.x GridSearchCV不会在详细模式下报告分数

Python 3.x GridSearchCV不会在详细模式下报告分数,python-3.x,machine-learning,scikit-learn,Python 3.x,Machine Learning,Scikit Learn,我正在python 3.8.5和sklearn 0.24.1上使用GridSearchCV运行参数网格: grid_search = GridSearchCV(estimator=xg_clf, scoring=make_scorer(matthews_corrcoef), param_grid=param_grid, n_jobs=args.n_jobs, verbose = 3) 根据文件, | verbose : int | Controls the verbosity:

我正在python 3.8.5和sklearn 0.24.1上使用GridSearchCV运行参数网格:

grid_search = GridSearchCV(estimator=xg_clf, scoring=make_scorer(matthews_corrcoef), param_grid=param_grid, n_jobs=args.n_jobs, verbose = 3)
根据文件,

 |  verbose : int
 |      Controls the verbosity: the higher, the more messages.
 |  
 |      - >1 : the computation time for each fold and parameter candidate is
 |        displayed;
 |      - >2 : the score is also displayed;
 |      - >3 : the fold and candidate parameter indexes are also displayed
 |        together with the starting time of the computation.
设置我设置的
verbose=3
,应该打印每次运行的马修斯相关系数

然而,输出是有限的

Fitting 5 folds for each of 480 candidates, totalling 2400 fits
[CV 1/5] END colsample_bytree=0.8, gamma=0, learning_rate=0.7, max_depth=3, n_estimators=200, subsample=0.9; total time=   0.2s
[CV 2/5] END colsample_bytree=0.8, gamma=0, learning_rate=0.7, max_depth=3, n_estimators=200, subsample=0.9; total time=   0.2s
[CV 3/5] END colsample_bytree=0.8, gamma=0, learning_rate=0.7, max_depth=3, n_estimators=200, subsample=0.9; total time=   0.2s
[CV 4/5] END colsample_bytree=0.8, gamma=0, learning_rate=0.7, max_depth=3, n_estimators=200, subsample=0.9; total time=   0.2s
[CV 5/5] END colsample_bytree=0.8, gamma=0, learning_rate=0.7, max_depth=3, n_estimators=200, subsample=0.9; total time=   0.2s
[CV 1/5] END colsample_bytree=0.8, gamma=0, learning_rate=0.7, max_depth=3, n_estimators=200, subsample=0.95; total time=   0.2s
为什么
GridSearchCV
不为每次运行打印MCC


可能这是因为我使用的是非标准记分器?

我尝试了一些类似于您的代码的东西,并使用了一些不同的sklearn版本。事实证明,0.24.1版在
verbose=3
时不会打印分数

以下是我的sklearn版本0.22.2.post1的代码和输出:

clf=XGBClassifier()
搜索=GridSearchCV(估计员=clf,得分=make\u记分员(马修斯•科考夫),
param_grid={'max_depth':[3,4,5]},verbose=3)
search.fit(X,y)
>3名候选人各5次试衣,共15次试衣
[CV]最大深度=3。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
[简历]。。。。。。。。。。。。。。。。。。。。。。。。。最大深度=3,得分=0.959,总得分=0.2s
以下是我的sklearn 0.24.1版代码和输出:

clf=XGBClassifier()
搜索=GridSearchCV(估计员=clf,得分=make\u记分员(马修斯•科考夫),
param_grid={'max_depth':[3,4,5]},verbose=3)
search.fit(X,y)
>3名候选人各5次试衣,共15次试衣
[CV 1/5]结束最大深度=3;总时间=0.2s
总之,您发现了一个bug。通常,我会建议在GitHub上打开一期,但您会很高兴知道0.24.2版会打印每个折叠的分数


您可以尝试
pip-install-scikit-learn--upgrade
pip-install-scikit-learn==0.24.1
来修复此问题。

您正在使用Google Colab吗?另外,请确保更新您的库以匹配您引用的文档。@ArturoSbr我从未听说过Google Colab。文档来自我笔记本电脑上的命令行。我提到GoogleColab是因为它是一个平台,在这个平台上,verbose似乎不能很好地工作。无论哪种方式,
xg\u clf
是xgboost对象吗?如果是这样,这可能就是为什么@ArturoSbr
xg_clf
确实是一个XGBoost对象的原因。XGBoost与GridSearchCV一起工作吗?