hi Ian,

yes you're right, however the dev version should be up to date:

http://scikit-learn.org/dev/modules/svm.html#svc

see note on scale_C parameter.

Alex

On Tue, Feb 14, 2012 at 10:49 PM, Ian Goodfellow
<[email protected]> wrote:
> This page says that SVC minimizes
> sum(square(w)) + C * sum(margins)
>
> I believe it actually minimizes
> sum(square(w)) + C * mean(margins)
>
> This may seem like a pedantic distinction but it's very important for
> being able to compare sklearn to other svm implementations.
>
> Am I correct that SVC minimizes the mean rather than the sum of the
> margins? If so the doc should be updated.
>
> The following script demonstrates that fitting two copies of X and y
> with C=1 is equivalent to fitting just X,y with C=1 and is not
> equivalent to fitting X,y with C=2. If SVC followed the doc we would
> expect the opposite result in both cases.
>
>
>
>
> import numpy as np
> rng = np.random.RandomState([1,2,3])
> from sklearn.svm import SVC
>
> svm_type = SVC(kernel = 'linear', C = 1.)
>
>
> X = rng.randn(100,5)
>
> W = rng.randn(5,5)
>
> y = np.dot(X,W).argmax(axis=1)
>
>
> print 'fitting svm 1'
> svm1 = svm_type.fit(X,y)
>
> print 'fitting svm 2'
> svm2 = svm_type.fit(np.concatenate([X,X],axis=0), 
> np.concatenate([y,y],axis=0))
>
> idiff = np.abs(svm1.intercept_-svm2.intercept_).max()
>
> wdiff = np.abs(svm1.coef_-svm2.coef_).max()
>
> print max(idiff,wdiff)
>
>
> svm3 = SVC(kernel = 'linear', C = 2.).fit(X,y)
>
> print np.abs(svm1.intercept_-svm3.intercept_).max()
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Scikit-learn-general mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to