Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using compute_sample_weight for the fit_params of cross_val_predict #13608

Open
AlexandraBomane opened this issue Apr 10, 2019 · 5 comments
Open

Comments

@AlexandraBomane
Copy link

I would like to know if it is possible to use "compute_sample_weight" within "cross_val_predict" to provide sample weights in fit_params?

I'm using the following code:
y_pred = cross_val_predict(clf, X, y, cv = cv, method = 'predict', fit_params = {'sample_weight':compute_sample_weight("balanced", y)})

But I think that it is not correct because compute_sample_weight("balanced", y) computes weights for all labels, whereas I would like that this function successively applied on each training set generated by the split operated by cross_val_predict. I think that the parameter "indices" of compute_sample_weight() could be a solution, but I don't know how to apply it.

@jnothman
Copy link
Member

jnothman commented Apr 10, 2019 via email

@AlexandraBomane
Copy link
Author

Which solution from this post could solve my problem?

@jnothman
Copy link
Member

@AlexandraBomane
Copy link
Author

I meant which feature of Imbalanced learn could help? Because I don't want to resample X and y, I just want to recalculate sample_weight according to X and y.

@jnothman
Copy link
Member

jnothman commented Apr 12, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants