Reputation: 1186
I'm trying to use RandomUnderSampler
. I have correctly installed the imblearn
module. But still getting the error: "Name 'RandomUnderSampler" is not defined`. Any specific reason for this? Can someone please help
from imblearn.under_sampling import RandomUnderSampler
#Random under-sampling and over-sampling with imbalanced-learn
def random_under_sampling(X,Y):
rus = RandomUnderSampler(return_indices=True)
X_rus, y_rus, id_rus = rus.fit_sample(X, Y)
print('Removed indexes:', id_rus)
plot_2d_space(X_rus, y_rus, 'Random under-sampling')
The actual method name
This is where I called my method
Upvotes: 1
Views: 5164
Reputation: 16660
Since it seems that you are using IPython it is important that you execute first the line importing imblearn
library (e.g. Ctrl-Enter
):
from imblearn.under_sampling import RandomUnderSampler
After that the module should get imported and the name of the function is going to be defined.
If this does not work, could you reload the notebook and execute all the statements up until the random_under_sampling
function to ensure nothing was missed?
Upvotes: 3