Scoring metric for multi-class cross validation

Viewed 246

I have a DataFrame X in which there is a column called target with 10 different labels: [0,1,2,3,4,5,6,7,8,9]. I have a Machine Learning model, let's say: model=AdaBoostClassifier() I would like to use to fit the data and predict again the labels by doing a cross-validation process to train the model. I use two metrics for the cross-validation, the accuracy and the neg_mean_squared_error to evaluate the performance and compute the ratio: neg_mean_squared_error/accuracy. The lines are like:

model.seed = 42

outer_cv = StratifiedKFold(n_splits=10, shuffle=True, random_state=1)

scoring=('accuracy', 'neg_mean_squared_error')

scores = cross_validate(model, X.drop(target,axis=1), X[target], cv=outer_cv, n_jobs=-1, scoring=scoring)

scores = abs(np.sqrt(np.mean(scores['test_neg_mean_squared_error'])*-1))/np.mean(scores['test_accuracy'])

score_description = [model,'{model}'.format(model=model.__class__.__name__),"%0.5f" % scores]

However, whenever I start to run, I get the following error message: ValueError: Samplewise metrics are not available outside of multilabel classification.

How could I do to solve this issue with the metrics and perform the corresponding classification? Which metrics could I use to evaluate the performance of the model in the multi-label case?

0 Answers
Related