lundi 10 août 2020

Setting random_state parameter to a fixed value does not cause RandomUnderSampler to generate same result every time I run the code

I have an imbalanced two class dataset and want to train a classifier using this data. I use the package imblearn for undersampling the major class and obtain a balanced dataset before training the classifier. Suppose I have stored the features in X and the labels in y. I use the following code for random undersampling:

from imblearn.under_sampling import RandomUnderSampler

resampler = RandomUnderSampler(random_state=0)
X_resampled, y_resampled = resampler.fit_sample(X, y)y

The problem is that despite I have set the parameter random_state to a fixed number, I get different results every time I run the above code. I want to get same set of samples by undersampling every time I run the code. How can I do that?

Thank you!




Aucun commentaire:

Enregistrer un commentaire