작성
·
818
0
안녕하세요. 좋은 강의 감사합니다.
실습 001. 템플릿을 주피터에서 사용하다 아래와 같은 에러가 발생하였는데 해결책을 찾지 못해 문의드립니다.
라이브러리의 import가 되지 않았다는 내용인 것 같아서, pip show imblearn도 해보았더니 unknown으로 나오는데 혹시 관련이 있는 내용인지요.
ImportError Traceback (most recent call last)
Cell In[3], line 5
3 import seaborn as sns
4 from sklearn.datasets import make_classification
----> 5 from imblearn.over_sampling import RandomOverSampler
6 from imblearn.under_sampling import RandomUnderSampler
File ~/anaconda3/lib/python3.11/site-packages/imblearn/__init__.py:52
48 sys.stderr.write("Partial import of imblearn during the build process.\n")
49 # We are not importing the rest of scikit-learn during the build
50 # process, as it may not be compiled yet
51 else:
---> 52 from . import (
53 combine,
54 ensemble,
55 exceptions,
56 metrics,
57 over_sampling,
58 pipeline,
59 tensorflow,
60 under_sampling,
61 utils,
62 )
63 from ._version import __version__
64 from .base import FunctionSampler
File ~/anaconda3/lib/python3.11/site-packages/imblearn/combine/__init__.py:5
1 """The :mod:`imblearn.combine` provides methods which combine
2 over-sampling and under-sampling.
3 """
----> 5 from ._smote_enn import SMOTEENN
6 from ._smote_tomek import SMOTETomek
8 __all__ = ["SMOTEENN", "SMOTETomek"]
File ~/anaconda3/lib/python3.11/site-packages/imblearn/combine/_smote_enn.py:12
9 from sklearn.base import clone
10 from sklearn.utils import check_X_y
---> 12 from ..base import BaseSampler
13 from ..over_sampling import SMOTE
14 from ..over_sampling.base import BaseOverSampler
File ~/anaconda3/lib/python3.11/site-packages/imblearn/base.py:21
18 from sklearn.utils.multiclass import check_classification_targets
20 from .utils import check_sampling_strategy, check_target_type
---> 21 from .utils._param_validation import validate_parameter_constraints
22 from .utils._validation import ArraysTransformer
25 class SamplerMixin(BaseEstimator, metaclass=ABCMeta):
File ~/anaconda3/lib/python3.11/site-packages/imblearn/utils/_param_validation.py:908
906 from sklearn.utils._param_validation import generate_valid_param # noqa
907 from sklearn.utils._param_validation import validate_parameter_constraints # noqa
--> 908 from sklearn.utils._param_validation import (
909 HasMethods,
910 Hidden,
911 Interval,
912 Options,
913 StrOptions,
914 _ArrayLikes,
915 _Booleans,
916 _Callables,
917 _CVObjects,
918 _InstancesOf,
919 _IterablesNotString,
920 _MissingValues,
921 _NoneConstraint,
922 _PandasNAConstraint,
923 _RandomStates,
924 _SparseMatrices,
925 _VerboseHelper,
926 make_constraint,
927 validate_params,
928 )
ImportError: cannot import name '_MissingValues' from 'sklearn.utils._param_validation' (/Users/marco_local/anaconda3/lib/python3.11/site-packages/sklearn/utils/_param_validation.py)
Name: imblearn
Version: 0.0
Summary: Toolbox for imbalanced dataset in machine learning.
Home-page: https://pypi.python.org/pypi/imbalanced-learn/
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Location: /Users/marco_local/anaconda3/lib/python3.11/site-packages
Requires: imbalanced-learn
Required-by:
Note: you may need to restart the kernel to use updated packages.
커널을 다시 시작해도 동일한 문제가 발생하여 문의드립니다.
답변 2
1
안녕하세요. 제가 stackoverflow 를 찾아보니 scikit-lean 의 최신 version (1.3.2)에 bug 가 있습니다. (https://stackoverflow.com/questions/76593906/how-to-resolve-cannot-import-name-missingvalues-from-sklearn-utils-param-v)
해결책은 다음과 같습니다.
anaconda prompt를 켜시고
pip uninstall scikit-learn 을 해서 현재 version을 삭제하신 후
pip install scikit-learn==1.2.2 으로 이전 version을 설치 하시면 문제 해결됩니다. (제가 테스트 해 보았습니다)
감사합니다.
0