try float(len(y_train)) - seems like C default is int...
Am 13.07.2013 00:10 schrieb "Anne Dwyer" <anne.p.dw...@gmail.com>:
> Peter,
>
> Thanks for your answers. When I scale C by len(y_train), I get the
> following error:
>
> ValueError: C <= 0
>
> Anne Dwyer
>
>
> On Fri, Jul 12, 2013 at 3:34 PM, Peter Prettenhofer <
> peter.prettenho...@gmail.com> wrote:
>
>> Hi Anne,
>>
>> I would also expect that using uniform weights should result in the same
>> solution as no weights -- but maybe there is an interaction with the C
>> parameter... for this we would need to know more about the internals of
>> libsvm and how it handles sample weights - try scaling C by
>> ``len(y_train)`` and see what you get :-)
>>
>> PS: if you use the linear svm implemented by SGDClassifier(loss='hinge')
>> you would also get this effect that uniform weights scale the
>> regularization parameter.
>>
>> best,
>> Peter
>>
>>
>> 2013/7/12 Anne Dwyer <anne.p.dw...@gmail.com>
>>
>>> I have been using the sonar data set (I believe this is a sample data
>>> set used in many demonstrations of machine learning.) It is a two class
>>> data set with 60 features with 208 training examples.
>>>
>>> I have a questions about using sample weights in fitting the SVM model.
>>>
>>> When I fit the model using scaled data, I get a test error of 10.3%.
>>> When I fit the model using a sample weight vector of 1/N, I get a test
>>> error of 37%.
>>>
>>> Here is the code:
>>>
>>> w=np.ones(len(y_train))
>>>
>>> clf=svm.SVC(kernel='rbf', C=10, gamma=.01)
>>> clf.fit(x_tr_scaled,y_train)
>>>
>>> score_scaled_tr=clf.score(x_tr_scaled,y_train)
>>>
>>> score_scaled_test=clf.score(x_te_scaled,y_test)
>>>
>>> w=w/sum(w)
>>>
>>> clf1=svm.SVC(kernel='rbf', C=10, gamma=.01, probability=True)
>>>
>>> clf1.fit(x_tr_scaled,y_train,sample_weight=w)
>>>
>>> print "Training score with sample weights is ", clf1.score(x_tr,y_train)
>>>
>>> print "Score with sample weights is", clf1.score(x_te_scaled,y_test)
>>>
>>> What am I doing wrong here?
>>>
>>> Also, when I tried this command:
>>>
>>> Pr=predict_proba(x_tr_scaled)
>>>
>>> I get the error that predict_proba is an undefined name. However, I got
>>> it from this link:
>>> http://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html#sklearn.svm.SVC
>>>
>>> Any help would be appreciated.
>>>
>>> Anne Dwyer
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> See everything from the browser to the database with AppDynamics
>>> Get end-to-end visibility with application monitoring from AppDynamics
>>> Isolate bottlenecks and diagnose root cause in seconds.
>>> Start your free trial of AppDynamics Pro today!
>>>
>>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>>> _______________________________________________
>>> Scikit-learn-general mailing list
>>> Scikit-learn-general@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>>
>>>
>>
>>
>> --
>> Peter Prettenhofer
>>
>>
>> ------------------------------------------------------------------------------
>> See everything from the browser to the database with AppDynamics
>> Get end-to-end visibility with application monitoring from AppDynamics
>> Isolate bottlenecks and diagnose root cause in seconds.
>> Start your free trial of AppDynamics Pro today!
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Scikit-learn-general mailing list
>> Scikit-learn-general@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>>
>>
>
>
> ------------------------------------------------------------------------------
> See everything from the browser to the database with AppDynamics
> Get end-to-end visibility with application monitoring from AppDynamics
> Isolate bottlenecks and diagnose root cause in seconds.
> Start your free trial of AppDynamics Pro today!
> http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
> _______________________________________________
> Scikit-learn-general mailing list
> Scikit-learn-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
>
>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general