Using the code below I get values for precision
, recall
, and F scores
but I get None
for support
import numpy as np
from sklearn.metrics import precision_recall_fscore_support
ytrue = np.array(['1', '1', '1', '1', '1','1','1','1','0'])
ypred = np.array(['0', '0', '0', '1', '1','1','1','1','0'])
precision_recall_fscore_support(ytrue, ypred, average='weighted')
output:
(0.91666666666666663, 0.66666666666666663, 0.72820512820512828, None)
I checked http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_fscore_support.html but I find it a bit unclear as to why it is None
Questions:
support
equal to None
in my output?None
output?Why is support equal to None in my output?
If a value for average
is provided, None
is returned for support
How do I get a non-None output?
Don't provide a value for average
. If you still want to use weighted
and need the support, just do something like
> from sklearn.metrics import confusion_matrix
> np.sum(confusion_matrix(ytrue, ypred), axis=1)
array([1, 8])