manuel-calzolari / sklearn-genetic

Genetic feature selection module for scikit-learn
https://sklearn-genetic.readthedocs.io
GNU Lesser General Public License v3.0
323 stars 77 forks source link

Passing sample_weight #23

Closed pmoradifar closed 3 years ago

pmoradifar commented 3 years ago

Hi,

Thanks for such a nice implementation of GA for feature selection.

I am having an issue with passing the sample_weight fit parameter while using GeneticSelectionCV. How this parameter should be passed while fitting GeneticSelectionCV?

Here are the details of my work:

The classifier I use is clf = XGBoostClassifier

For feature selection I use the following code where the rest of the parameters are the default ones:

genetic_CV = GeneticSelectionCV(estimator=clf)

Since I need to preprocess my data before fitting, I basically use the following pipeline for feature selection using GeneticSelectionCV:

ga_pipeline = Pipeline( steps=[('preprocessing',preprocessor), ('ga',genetic_CV)])

I think normally the fit parameter sample_weight should be passed like:

ga_pipeline.fit(X_train, y_train, ga__sample_weight=_weight_)

but it raises an error:

fit() got an unexpected keyword argument sample_weight