I am getting an import Error when trying to import imblearn.over_sampling for RandomOverSampler. I believe the issue is not with my code but with the libraries clashing, I’m not sure though.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn.preprocessing import StandardScaler #actually scikit-learn
from imblearn.over_sampling import RandomOverSampler
code that’s using StandardScaler and RandomOverSampler:
def scale_dataset(dataframe, oversample=False):
X = dataframe[dataframe.columns[:-1]].values
Y = dataframe[dataframe.columns[-1]].values
scaler = StandardScaler()
X = scaler.fit_transform(X)
if oversample:
ros = RandomOverSampler()
X, Y = ros.fit_resample(X,Y)
data = np.hstack((X, np.reshape(Y, (-1, 1))))
return data, X, Y
print(len(train[train["class"]==1]))
print(len(train[train["class"]==0]))
train, X_train, Y_train = scale_dataset(train, True)
I tried fully importing sklearn, uninstalled and reinstalled scipi and sklearn (as scikit-learn), installing Tensorflow.
I do have numpy, scipy, pandas and other dependent libraries installed.
Matt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.