导入imblearn 报错 解决了2天 还没成功
显示导入错误 重新装了多遍环境 安装卸载conda 都不行 求大神指导 多谢
错误
代码
# Undersample imbalanced dataset with NearMiss-3
from collections import Counter
from sklearn.datasets import make_classification
from imblearn.under_sampling import NearMiss
from matplotlib import pyplot
from numpy import where
# define dataset
X, y = make_classification(n_samples=10000, n_features=2, n_redundant=0,
n_clusters_per_class=1, weights=[0.99], flip_y=0, random_state=1)
# summarize class distribution
counter = Counter(y)
print(counter)
# define the undersampling method
undersample = NearMiss(version=3, n_neighbors_ver3=3)
# transform the dataset
X, y = undersample.fit_resample(X, y)
# summarize the new class distribution
counter = Counter(y)
print(counter)
# scatter plot of examples by class label
for label, _ in counter.items():
row_ix = where(y == label)[0]
pyplot.scatter(X[row_ix, 0], X[row_ix, 1], label=str(label))
pyplot.legend()
pyplot.show()
I got nothing wrong after install imblearn which is not installed under conda.
Maybe you can check if the version of sklearn.version is < “1.2”. The version of my isnstalled sklearn is ‘1.1.2’.
or
After I upgrade scikit-learn
then I got same exception as yours