I am trying to classify my dataset using keras but I am getting ValueError: Classification metrics can't handle a mix of multiclass and multilabel-indicator targets
error. values in y_pred
are as following
array([[2.95522604e-02, 9.70325887e-01, 3.20542094e-05, ...,
1.74383260e-07, 1.98587145e-07, 9.88743452e-08],
[3.25102806e-01, 6.68996394e-01, 1.65001326e-03, ...,
5.84201662e-05, 5.91963508e-05, 4.68929684e-05],
[8.87618303e-01, 1.12024814e-01, 1.22764613e-04, ...,
1.44616331e-06, 1.33618846e-06, 1.68983024e-06],
...,
[3.09438616e-01, 6.83520675e-01, 1.94711238e-03, ...,
7.57295784e-05, 7.51852640e-05, 5.94857411e-05],
[6.73729360e-01, 3.21534157e-01, 1.41171378e-03, ...,
4.93246625e-05, 4.61974196e-05, 4.73670734e-05],
[1.33120596e-01, 8.64127636e-01, 7.41749362e-04, ...,
1.87505502e-05, 1.95825924e-05, 1.34223355e-05]], dtype=float32)
I am rounding them up as mentioned in this question as y_test
values are
array([1, 0, 0, ..., 0, 1, 1])
After rounding y_pred
with y_pred = y_pred.round().astype(int)
I have
array([[0, 1, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 0],
...,
[0, 1, 0, ..., 0, 0, 0],
[1, 0, 0, ..., 0, 0, 0],
[0, 1, 0, ..., 0, 0, 0]])
Bit even after this when i try to get classification report using print(metrics.classification_report(y_test, y_pred))
I get same error as above mentioned. Can someone help me about what am I doing wrong here? Thank you