How to compute f1_score for multiclass multilabel classification
I have used one hot encoder [1,0,0][0,1,0][0,0,1] for my functional classification model
.
The predicted probabilities for test data yprob = model.predict(testX)
gives me :
yprob = array([[0.18120882, 0.5803128 , 0.22847839],
[0.0101245 , 0.12861261, 0.9612609 ],
[0.16332535, 0.4925239 , 0.35415074],
...,
[0.9931931 , 0.09328955, 0.01351734],
[0.48841736, 0.25034943, 0.16123319],
[0.3807928, 0.42698202, 0.27493873]], dtype=float32)
I would like to compute the Accuracy, F1 score and the confusion matrix from this.
The sequential api offers a predict_classes
function to do it.
yclasses = model.predict_classes(testX)
and using the f1_score function of sklearn we could compute all those values.
How could I apply it to predict probabilities of test data for multiclass multilabel classification ?
My second question is to know if the highest value of each array of yprob = model.predict(testX)
corresponds to the predicted class ? for example, [0.18120882, 0.5803128 , 0.22847839]
is the first element in the array. The highest value is 0.5803128
. Does it mean that it corresponds to the one hot encoder [0, 1, 0], so the second label
because it is the second element in the array ?
Topic f1score multiclass-classification deep-learning accuracy scikit-learn
Category Data Science