On 3 November 2011 08:43, Satrajit Ghosh <[email protected]> wrote:
> hi robert,
>
>
> If you look at classification report it returns:
>
> ---
>
> precision recall f1-score support
>
> -1 0.53 0.44 0.48 18
> 1 0.63 0.71 0.67 24
>
> avg / total 0.59 0.60 0.59 42
>
> ---
>
> but if you call f1_score(y_true, y_pred) it always returns the positive
> f1-score (.67 in the above example) and i would like to get the average
> f1-score for the two classes i.e. .59.
>
>
> cheers,
>
> satra
>
> On Wed, Nov 2, 2011 at 5:38 PM, Robert Layton <[email protected]>wrote:
>
>>
>> On 3 November 2011 08:32, Satrajit Ghosh <[email protected]> wrote:
>>
>>> how do i get at the average f1_score if i have two labels 1 and -1 or 1
>>> and 0? it always seems to return the positive one.
>>>
>>> cheers,
>>>
>>> satra
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> RSA(R) Conference 2012
>>> Save $700 by Nov 18
>>> Register now
>>> http://p.sf.net/sfu/rsa-sfdev2dev1
>>> _______________________________________________
>>> Scikit-learn-general mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>>
>>>
>>
>> I'm not sure I understand your problem.
>> To clarrify, your labels are something like:
>>
>> labels_a = [1,-1,1,1,1,-1]
>> labels_b = [0, 1,1,1,0,0]
>>
>> And you want to calculate the f_1?
>>
>> f_1 should always be positive - its the harmonic mean of precision and
>> recall, both of which are bounded in [0,1].
>>
>>
>> --
>>
>>
>> My public key can be found at: http://pgp.mit.edu/
>> Search for this email address and select the key from "2011-08-19" (key
>> id: 54BA8735)
>> Older keys can be used, but please inform me beforehand (and update when
>> possible!)
>>
>>
>>
>> ------------------------------------------------------------------------------
>> RSA(R) Conference 2012
>> Save $700 by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Scikit-learn-general mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>
>>
>
>
> ------------------------------------------------------------------------------
> RSA(R) Conference 2012
> Save $700 by Nov 18
> Register now
> http://p.sf.net/sfu/rsa-sfdev2dev1
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
I'll have to have a further look soon, but you can calculate this value
yourself using:
p, r, f1, support = precision_recall_fscore_support(y_true, y_pred)
f = np.average(f1, weights=support)
Alternatively, ignore the weights keyword for the micro-average.
The issue is that when there are only two classes, there is a "positive"
class, and the f1 is returned (see the __doc__ of fbeta_score in the
metrics/metrics.py module). It doesn't account for the times when there are
two classes, not just a "positive and negative", but two actual classes.
If you submit a bug request, I'll work on this soon (bit busy at the
moment!)
Thanks,
Robert
--
My public key can be found at: http://pgp.mit.edu/
Search for this email address and select the key from "2011-08-19" (key id:
54BA8735)
Older keys can be used, but please inform me beforehand (and update when
possible!)
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general