【发布时间】:2021-06-29 09:53:16
【问题描述】:
from sklearn.model_selection import cross_validate
scores = cross_validate(LogisticRegression(class_weight='balanced',max_iter=100000),
X,y, cv=5, scoring=('roc_auc', 'average_precision','f1','recall','balanced_accuracy'))
scores['test_roc_auc'].mean(), scores['test_average_precision'].mean(),scores['test_f1'].mean(),scores['test_recall'].mean(),scores['test_balanced_accuracy'].mean()
如何在上述交叉验证评分参数下计算以下 G-mean:
from imblearn.metrics import geometric_mean_score
print('The geometric mean is {}'.format(geometric_mean_score(y_test, y_test_pred)))
或
from sklearn.metrics import accuracy_score
g_mean = 1.0
#
for label in np.unique(y_test):
idx = (y_test == label)
g_mean *= accuracy_score(y_test[idx], y_test_pred[idx])
#
g_mean = np.sqrt(g_mean)
score = g_mean
print(score)
【问题讨论】:
标签: python machine-learning scikit-learn classification