Making ROC curve using python for multiclassification

后端 未结 2 1451
抹茶落季
抹茶落季 2021-01-14 17:40

Following up from here: Converting a 1D array into a 2D class-based matrix in python

I want to draw ROC curves for each of my 46 classes. I have 300 test samples for

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-14 18:02

    roc_curve takes parameter with shape [n_samples] (link), and your inputs (either y_test_bi or y_pred_bi) are of shape (300, 46). Note the first

    I think the problem is y_pred_bi is an array of probabilities, created by calling clf.predict_proba(X) (please confirm this). Since your classifier was trained on all 46 classes, it outputs a 46-dimensional vectors for each data point, and there is nothing label_binarize can do about that.

    I know of two ways around this:

    1. Train 46 binary classifiers by invoking label_binarize before clf.fit() and then compute ROC curve
    2. Slice each column of the 300-by-46 output array and pass that as the second parameter to roc_curve. This is my preferred approach by I am assuming y_pred_bi contains probabilities

提交回复
热议问题