gpt4 book ai didi

python - sklearn auc 分数 - diffmetrics.roc_auc_score & model_selection.cross_val_score

转载 作者:行者123 更新时间:2023-11-30 09:07:00 25 4
gpt4 key购买 nike

刚接触 sklearn,请保持温柔。使用不同的 roc_auc 评分计算客户流失率,我得到 3 个不同的分数。分数 1 和 3 接近,分数与分数 2 之间存在显着差异。感谢您指导为什么会出现这种差异以及哪一个可能是首选?非常感谢!

from sklearn.model_selection import cross_val_score
from sklearn.metrics import roc_auc_score


param_grid = {'n_estimators': range(10, 510, 100)}
grid_search = GridSearchCV(estimator=RandomForestClassifier(criterion='gini', max_features='auto',
random_state=20), param_grid=param_grid, scoring='roc_auc', n_jobs=4, iid=False, cv=5, verbose=0)
grid_search.fit(self.dataset_train, self.churn_train)
score_roc_auc = np.mean(cross_val_score(grid_search, self.dataset_test, self.churn_test, cv=5, scoring='roc_auc'))
"^^^ SCORE1 - 0.6395751751133528

pred = grid_search.predict(self.dataset_test)
score_roc_auc_2 = roc_auc_score(self.churn_test, pred)
"^^^ SCORE2 - 0.5063261397640454

print("grid best score ", grid_search.best_score_)
"^^^ SCORE3 - 0.6473102070034342

最佳答案

我相信下面的链接可以回答这个问题,它指向 GridSearchCV 中的折叠和较小分割的评分?

Difference in ROC-AUC scores in sklearn RandomForestClassifier vs. auc methods

关于python - sklearn auc 分数 - diffmetrics.roc_auc_score & model_selection.cross_val_score,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49544509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com