Hi Roberto,
Everything I say below is also explained in the developers documentation that I
linked to in the other e-mail. [1]
You are breaking some conventions that make the default `get_params` and
`set_params` not work well.
As I said in the other thread, fitted attributes are suffixed with an
underscore (`self.my_param_`) and you shouldn’t initialize them in `__init__`.
`__init__` should be used only to set parameters that the user should specify
(think of the C regularization value from logistic regression). Underscored
attributes are things that are calculated during fitting (think of the `coef_`
attribute of logistic regression). Your estimator’s parameters should fall
into one of these two categories, think about which one it is, and name them
accordingly.
Also, all parameters you set in `__init__` MUST come from the user. You should
move your `self.var_ = #something` line to fit, rather than init.
Here’s an example of an `__init__` function:
```
def __init__(self, fit_intercept=True, normalize=False, copy_X=True, n_jobs=1):
self.fit_intercept = fit_intercept
self.normalize = normalize
self.copy_X = copy_X
self.n_jobs = n_jobs
```
Note how all attributes set take the values passed by the user without change,
and the names are not changed.
If you satisfy these conventions, the default `get_params` and `set_params`
will work, and your code will be easier to read and modify by people familiar
with the scikit-learn standards.
Of course, you don’t have to satisfy these conventions, but then you must
implement `get_params` and `set_params` to account for all non-standard things
you are trying to do. The developer documentation explains what these functions
are supposed to do.
>
> 1) Except for the first iteration of grid search, all other times the
> lists I print from within __init__() function are None
I’m not 100% sure but I think this is expected. You are only printing things
from `__init__`, but grid search might end up calling `set_params` on the same
object, rather than building a new one (depends on whether n_jobs > 1?). Your
estimator should support this.
Best,
Vlad
[1]
http://scikit-learn.org/stable/developers/index.html#rolling-your-own-estimator
------------------------------------------------------------------------------
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=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Scikit-learn-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general