Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Support = 'None'

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:

  1. Why is support equal to None in my output?
  2. How do I get a non-None output?

1 Answers

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])
like image 109
cosmosa Avatar answered Oct 18 '25 01:10

cosmosa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!