Hi.
Which version of scikit-learn are you using?
Andy


On 03/26/2012 03:07 PM, xinfan meng wrote:
Alex, I am afraid some codes have been broken...

In [127]: X = [[0], [1]]

In [129]: Y = [0, 1]

In [130]: clf.fit(X, Y)
Out[130]:
SVC(C=1.0, cache_size=200, coef0=0.0, degree=3, gamma=0.0, kernel='linear',
  probability=False, scale_C=False, shrinking=True, tol=0.001)

In [132]: clf.decision_function(X)
Out[132]:
array([[-0.5],
       [ 0.5]])

In [133]: X2 = [[1], [0]]

In [134]: Y2 = [1, 0]

In [135]: clf.fit(X2, Y2)
Out[135]:
SVC(C=1.0, cache_size=200, coef0=0.0, degree=3, gamma=0.0, kernel='linear',
  probability=False, scale_C=False, shrinking=True, tol=0.001)

In [137]: clf.decision_function(X2)
Out[137]:
array([[ 0.5],
       [-0.5]])

On Mon, Mar 26, 2012 at 8:59 PM, Alexandre Gramfort <[email protected] <mailto:[email protected]>> wrote:

    hi,

    from what I remember we fixed the random label ordering problem
    at least for the 2 classes case.

    can you check that things behave fine and the same way with  Y = [0,
    1] and Y = [1, 0]?

    Alex

    On Mon, Mar 26, 2012 at 5:00 AM, xinfan meng <[email protected]
    <mailto:[email protected]>> wrote:
    > I use the following codes to obtain decision values for SVC
    classifier clf.
    >
    >
    
-----------------------------------------------------------------------------------------------
    >
    > In [5]: >>> clf = svm.SVC()
    >
    > In [23]: >>> X = [[0], [1], [2]]
    >
    > In [24]: >>> Y = [0, 1, 2]
    >
    > In [25]: clf.fit(X, Y)
    > Out[25]:
    > SVC(C=1.0, cache_size=200, coef0=0.0, degree=3, gamma=1.0,
    kernel='rbf',
    >   probability=False, scale_C=False, shrinking=True, tol=0.001)
    >
    > In [26]: clf.predict([[0]])
    > Out[26]: array([ 0.])
    >
    > In [27]: clf.predict(X)
    > Out[27]: array([ 0.,  1.,  2.])
    >
    > In [28]: clf.decision_function(X)
    > Out[28]:
    > array([[-0.63212056, -0.98168436, -0.3495638 ],
    >        [ 0.63212056, -0.        , -0.63212056],
    >        [ 0.3495638 ,  0.98168436,  0.63212056]])
    >
    >
    
-----------------------------------------------------------------------------------------------
    >
    >
    >
    > The decision_function return confusing results.  Why [-0.63212056,
    > -0.98168436, -0.3495638 ] corresponds to label 0 ?
    > The encoding of labels seems to be different from the natural
    orders of (0,
    > 1, 2 ...) .
    > After reading the README file of LibSVM, I found the label
    encoding can be
    > obtained by calling svm_get_labels().
    > Where can I find this function wrapper in sklearn? Without that,
    the return
    > results of decision_function() are difficult to interpret.
    > Thanks!
    >
    > --
    > Best Wishes
    > --------------------------------------------
    > Meng Xinfan(蒙新泛)
    > Institute of Computational Linguistics
    > Department of Computer Science & Technology
    > School of Electronic Engineering & Computer Science
    > Peking University
    > Beijing, 100871
    > China
    >
    >
    
------------------------------------------------------------------------------
    > This SF email is sponsosred by:
    > Try Windows Azure free for 90 days Click Here
    > http://p.sf.net/sfu/sfd2d-msazure
    > _______________________________________________
    > Scikit-learn-general mailing list
    > [email protected]
    <mailto:[email protected]>
    > https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
    >

    
------------------------------------------------------------------------------
    This SF email is sponsosred by:
    Try Windows Azure free for 90 days Click Here
    http://p.sf.net/sfu/sfd2d-msazure
    _______________________________________________
    Scikit-learn-general mailing list
    [email protected]
    <mailto:[email protected]>
    https://lists.sourceforge.net/lists/listinfo/scikit-learn-general




--
Best Wishes
--------------------------------------------
Meng Xinfan(蒙新泛)
Institute of Computational Linguistics
Department of Computer Science & Technology
School of Electronic Engineering & Computer Science
Peking University
Beijing, 100871
China


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure


_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to