<div dir="ltr">You can use a pipeline object to contain both feature selection/transformation steps and an estimator. All elements of a pipeline can then be tuned using gridsearch. You can see a simple example here: <a href="http://scikit-learn.org/stable/modules/pipeline.html">http://scikit-learn.org/stable/modules/pipeline.html</a> <div><br></div><div>You may also be interested seeing if the FeatureUnion object can serve the same purpose as your FeatureMultiplier.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 7, 2016 at 2:03 PM, Piotr Bialecki <span dir="ltr"><<a href="mailto:piotr.bialecki@hotmail.de" target="_blank">piotr.bialecki@hotmail.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi all,<br>
<br>
I am currently tuning some parameters of my xgboost model using scikit's grid_search, e.g.:<br>
<br>
param_test1 = {'max_depth':range(3,10,2),<br>
'min_child_weight':range(1,6,<wbr>2)<br>
}<br>
gsearch1 = GridSearchCV(estimator = XGBClassifier(learning_rate =0.1, n_estimators=762,<br>
max_depth=5, min_child_weight=1, gamma=0,
<br>
subsample=0.8, colsample_bytree=0.8,<br>
objective= 'binary:logistic', nthread=4,
<br>
scale_pos_weight=1, seed=2809),
<br>
param_grid = param_test1, <br>
scoring='roc_auc',<br>
n_jobs=6,<br>
iid=False, cv=5)<br>
<br>
Before that I preprocessed my dataset X with some different methods.<br>
These preprocessing steps have some parameters too, which I would like to tune.<br>
I know that it is possible to tune the parameters of the preprocessing steps, <br>
if they are part pf my pipeline. <br>
E.g. if I am using PCA, I could tune the parameter n_components, right?<br>
<br>
But what if I have some "custom" preprocessing code with some parameters?<br>
Is it possible to create a scikit-compatible "object"<strong></strong><strong></strong><strong></strong> of my custom code in order to tune the<br>
parameters in the pipeline with grid search?<br>
Imagine I would like to write a custom method FeatureMultiplier() with a parameter multiplier_value.<br>
Is it possible to create a scikit-compatible class out of this method and tune it with grid search?<br>
<br>
I thought I saw a talk about exactly this topic at some PyData in 2016 or 2015,<br>
but unfortunately I cannot find the video of it.<br>
Maybe I misunderstood the presentation at that time.<br>
<br>
<br>
Best regards,<br>
Piotr<br>
</div>
<br>______________________________<wbr>_________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/scikit-learn</a><br>
<br></blockquote></div><br></div>