gpt4 book ai didi

python - 不平衡-学习: Import Error: cannot import name 'MultiOutputMixin'

转载 作者:行者123 更新时间:2023-12-02 19:40:36 25 4
gpt4 key购买 nike

我已经重新安装了最新的 scikit-learn 和不平衡学习。我还检查了所有其他库,以确保它们与不平衡学习兼容。

我只想运行一个简单的RandomOverSample(),但我收到以下导入错误消息:

import imblearn
from imblearn.over_sampling import RandomOverSampler

ros = RandomOverSampler()
X_ros, y_ros = ros.fit_sample(x, y)

错误:消息:

    ---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-122-0bf7409a8688> in <module>
----> 1 import imblearn
2 from imblearn.over_sampling import RandomOverSampler
3
4 ros = RandomOverSampler()
5 X_ros, y_ros = ros.fit_sample(x, y)

~/.local/lib/python3.5/site-packages/imblearn/__init__.py in <module>
32 Module which allowing to create pipeline with scikit-learn estimators.
33 """
---> 34 from . import combine
35 from . import ensemble
36 from . import exceptions

~/.local/lib/python3.5/site-packages/imblearn/combine/__init__.py in <module>
3 """
4
----> 5 from ._smote_enn import SMOTEENN
6 from ._smote_tomek import SMOTETomek
7

~/.local/lib/python3.5/site-packages/imblearn/combine/_smote_enn.py in <module>
8 from sklearn.utils import check_X_y
9
---> 10 from ..base import BaseSampler
11 from ..over_sampling import SMOTE
12 from ..over_sampling.base import BaseOverSampler

~/.local/lib/python3.5/site-packages/imblearn/base.py in <module>
14 from sklearn.utils.multiclass import check_classification_targets
15
---> 16 from .utils import check_sampling_strategy, check_target_type
17 from .utils._validation import ArraysTransformer
18

~/.local/lib/python3.5/site-packages/imblearn/utils/__init__.py in <module>
5 from ._docstring import Substitution
6
----> 7 from ._validation import check_neighbors_object
8 from ._validation import check_target_type
9 from ._validation import check_sampling_strategy

~/.local/lib/python3.5/site-packages/imblearn/utils/_validation.py in <module>
11
12 from sklearn.base import clone
---> 13 from sklearn.neighbors._base import KNeighborsMixin
14 from sklearn.neighbors import NearestNeighbors
15 from sklearn.utils import column_or_1d

~/.local/lib/python3.5/site-packages/sklearn/neighbors/_base.py in <module>
21 from ._ball_tree import BallTree
22 from ._kd_tree import KDTree
---> 23 from ..base import BaseEstimator, MultiOutputMixin
24 from ..metrics import pairwise_distances_chunked
25 from ..metrics.pairwise import PAIRWISE_DISTANCE_FUNCTIONS

ImportError: cannot import name 'MultiOutputMixin'

最佳答案

尝试打开新的 python 控制台或重新启动 jupyter 笔记本。这对我有用。看起来 imblearn 库需要重新启动才能工作。这个问题也在这里讨论。 ImportError: cannot import name 'MultiOutputMixin' from 'sklearn.base'

关于python - 不平衡-学习: Import Error: cannot import name 'MultiOutputMixin' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60254805/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com