Reputation: 1395
I'm performing classification on a dataset and I'm using cross-validation for modelling. The cross-validation gives accuracy for each fold since the class are imbalances, accuracy is not correct measure. I want to get AUC-ROC instead of accuracy.
Upvotes: 0
Views: 588
Reputation: 16966
The cross_val_score
support a large number of scoring options.
The exhaustive list is mentioned here.
['accuracy', 'recall_samples', 'f1_macro', 'adjusted_rand_score', 'recall_weighted', 'precision_weighted', 'recall_macro', 'homogeneity_score', 'neg_mean_squared_log_error', 'recall_micro', 'f1', 'neg_log_loss', 'roc_auc', 'average_precision', 'f1_weighted', 'r2', 'precision_macro', 'explained_variance', 'v_measure_score', 'neg_mean_absolute_error', 'completeness_score', 'fowlkes_mallows_score', 'f1_micro', 'precision_samples', 'mutual_info_score', 'neg_mean_squared_error', 'balanced_accuracy', 'neg_median_absolute_error', 'precision_micro', 'normalized_mutual_info_score', 'adjusted_mutual_info_score', 'precision', 'f1_samples', 'brier_score_loss', 'recall']
Here is an example to showcase how to use auc_roc
.
>>> from sklearn import datasets, linear_model
>>> from sklearn.model_selection import cross_val_score
>>> import numpy as np
>>> X, y = datasets.load_breast_cancer(return_X_y=True)
>>> model = linear_model.SGDClassifier(max_iter=50, random_state=7)
>>> print(cross_val_score(model, X, y, cv=5, scoring = 'roc_auc'))
[0.96382429 0.96996124 0.95573441 0.96646546 0.91113347]
Upvotes: 1