aerdem4 / lofo-importance

Leave One Feature Out Importance
MIT License
810 stars 83 forks source link

Sample_weight? #31

Closed kmedved closed 4 years ago

kmedved commented 4 years ago

Is there any way to pass a sample weight column into a Dataset object, or is there any plan to add this functionality? It should fit pretty smoothly into the sklearn framework I would expect, but maybe I'm missing something.

Thanks for the wonderful package!

aerdem4 commented 4 years ago

@kmedved Thanks for your question. You can pass your sample weights to LOFOImportance in fit_params. Example:

fi = LOFOImportance(dataset, scoring=scorer, model=LinearRegression(), cv=cv, 
                    fit_params={"sample_weight": df["sw"].values})

Let me know if it works for you.

kmedved commented 4 years ago

Excellent - that worked great. Thanks for the quick reply. That functionality really helps makes this a first-rate feature selection tool.

Eager to watch for future improvements.