The explanation for the "inconsistency" is simple: This is not a
supported feature, but we don't explicitly disallow it if it would do
the expected thing.
As Lars said, for SVC it will not do the expected thing, so it is forbidden.
If you just have a linear binary classifier, you can just compute the
dot-product without an estimator.
If you want to have an estimator, you can use your coef_ on any of the
estimators that allow setting it.
For multi-class, I think SVC uses OVO and LinearSVC uses OVR (or was it
the other way around?) so you can't really use the coef of one on the other.
Hth,
Andy
On 11/18/2014 10:38 AM, Chris Holdgraf wrote:
Hey all - I am trying to figure out how to manually set the
coefficients of a model, but am encountering some inconsistencies in
whether this is possible with sklearn. It seems that some models allow
you to do this, while others don't.
My use case is that I'm fitting a ton of models, and cross-validating
each one 10 times. So I have a 3-D matrix of n_models X n_cvs X
n_coef_per_model.
What I want to do is now average across all the CVs, then run another
set of predictions with each model.
I have tried doing this by simply storing a 3-D matrix of coefficient
data from each fit, and another matrix of the intercept of each fit. I
then create an object for the model I want to predict and manually set
its attributes. E.g., model.coef_ = this_coef, model.intercept_ =
this_intercept.
Sometimes this works, but sometimes it doesn't. For example, if I use
LinearSVC as my model, then setting .coef_ works fine. However, if I
use SVC(kernel='linear'), then I get an attribute error when I try to
set any attribute.
Can someone explain the inconsistency in behavior here? Is there a
better way to do things like this in sklearn?
Thanks,
Chris
--
_____________________________________
PhD Candidate in Neuroscience | UC Berkeley <http://hwni.org/>
Editor and Web Master | Berkeley Science Review
<http://sciencereview.berkeley.edu/>
_____________________________________
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=157005751&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general