inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

[개정판] 파이썬 머신러닝 완벽 가이드

분류 실습 2: 신용카드 사기 예측 실습 - 05

imblearn 관련

2247

watashia0521

작성한 질문수 4

0

imblearn을 설치 후 실행 시 아래와 같은 오류가 발생합니다.
(영상에서는 imblearn Version이 0.9.0인데, 저는 0.7.0으로 설치가 되었네요) 구글링으로 해결이 되지 않아... 해결방법을 문의드립니다.
 

통계 머신러닝 배워볼래요? python

답변 5

0

watashia0521

다운그레이드 후 정상 동작합니다!! 빠른 회신과 정확한 답변에 감탄했습니다. 정말 감사합니다 👍🏻

0

권 철민

imblearn과 scikit learn 1.1.2 가 잘 안맞는 것 같군요. 

1.1.2는 2022년 8월 출시 버전인데 최근에 사이킷런을 upgrade하신것 같군요. 

사이킷런을 설치하면 threadpoolctl 모듈도 같이 설치하는데 이게 뭔가 버전이 잘 안맞는 것 같습니다. 

pip로 설치하셨으면 pip uninstall scikit-learn으로 사이킷런을 삭제하신 후에 pip install scikit-learn==1.0.2 로 scikit learn을 downgrade 해보시지요

conda로 하셨으면 conda install scikit-learn=1.0.2 로 해보시지요. 

0

watashia0521

오류 전체 메세지 입니다!!





---------------------------------------------------------------------------
AttributeError Traceback (most recent call last) Input In [30], in <cell line: 4>() 1 from imblearn.over_sampling import SMOTE 3 smote = SMOTE(random_state=0) ----> 4 X_train_over, y_train_over = smote.fit_resample(X_train, y_train) 5 print('SMOTE 적용 전 학습용 피처/레이블 데이터 세트: ', X_train.shape, y_train.shape) 6 print('SMOTE 적용 후 학습용 피처/레이블 데이터 세트: ', X_train_over.shape, y_train_over.shape) File ~/opt/anaconda3/lib/python3.9/site-packages/imblearn/base.py:83, in SamplerMixin.fit_resample(self, X, y) 77 X, y, binarize_y = self._check_X_y(X, y) 79 self.sampling_strategy_ = check_sampling_strategy( 80 self.sampling_strategy, y, self._sampling_type 81 ) ---> 83 output = self._fit_resample(X, y) 85 y_ = ( 86 label_binarize(output[1], classes=np.unique(y)) if binarize_y else output[1] 87 ) 89 X_, y_ = arrays_transformer.transform(output[0], y_) File ~/opt/anaconda3/lib/python3.9/site-packages/imblearn/over_sampling/_smote/base.py:324, in SMOTE._fit_resample(self, X, y) 321 X_class = _safe_indexing(X, target_class_indices) 323 self.nn_k_.fit(X_class) --> 324 nns = self.nn_k_.kneighbors(X_class, return_distance=False)[:, 1:] 325 X_new, y_new = self._make_samples( 326 X_class, y.dtype, class_sample, X_class, nns, n_samples, 1.0 327 ) 328 X_resampled.append(X_new) File ~/opt/anaconda3/lib/python3.9/site-packages/sklearn/neighbors/_base.py:763, in KNeighborsMixin.kneighbors(self, X, n_neighbors, return_distance) 756 use_pairwise_distances_reductions = ( 757 self._fit_method == "brute" 758 and PairwiseDistancesArgKmin.is_usable_for( 759 X if X is not None else self._fit_X, self._fit_X, self.effective_metric_ 760 ) 761 ) 762 if use_pairwise_distances_reductions: --> 763 results = PairwiseDistancesArgKmin.compute( 764 X=X, 765 Y=self._fit_X, 766 k=n_neighbors, 767 metric=self.effective_metric_, 768 metric_kwargs=self.effective_metric_params_, 769 strategy="auto", 770 return_distance=return_distance, 771 ) 773 elif ( 774 self._fit_method == "brute" and self.metric == "precomputed" and issparse(X) 775 ): 776 results = _kneighbors_from_graph( 777 X, n_neighbors=n_neighbors, return_distance=return_distance 778 ) File sklearn/metrics/_pairwise_distances_reduction.pyx:698, in sklearn.metrics._pairwise_distances_reduction.PairwiseDistancesArgKmin.compute() File ~/opt/anaconda3/lib/python3.9/site-packages/sklearn/utils/fixes.py:151, in threadpool_limits(limits, user_api) 149 return controller.limit(limits=limits, user_api=user_api) 150 else: --> 151 return threadpoolctl.threadpool_limits(limits=limits, user_api=user_api) File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:171, in threadpool_limits.__init__(self, limits, user_api) 167 def __init__(self, limits=None, user_api=None): 168 self._limits, self._user_api, self._prefixes = \ 169 self._check_params(limits, user_api) --> 171 self._original_info = self._set_threadpool_limits() File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:268, in threadpool_limits._set_threadpool_limits(self) 265 if self._limits is None: 266 return None --> 268 modules = _ThreadpoolInfo(prefixes=self._prefixes, 269 user_api=self._user_api) 270 for module in modules: 271 # self._limits is a dict {key: num_threads} where key is either 272 # a prefix or a user_api. If a module matches both, the limit 273 # corresponding to the prefix is chosed. 274 if module.prefix in self._limits: File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:340, in _ThreadpoolInfo.__init__(self, user_api, prefixes, modules) 337 self.user_api = [] if user_api is None else user_api 339 self.modules = [] --> 340 self._load_modules() 341 self._warn_if_incompatible_openmp() 342 else: File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:371, in _ThreadpoolInfo._load_modules(self) 369 """Loop through loaded libraries and store supported ones""" 370 if sys.platform == "darwin": --> 371 self._find_modules_with_dyld() 372 elif sys.platform == "win32": 373 self._find_modules_with_enum_process_module_ex() File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:428, in _ThreadpoolInfo._find_modules_with_dyld(self) 425 filepath = filepath.decode("utf-8") 427 # Store the module if it is supported and selected --> 428 self._make_module_from_path(filepath) File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:515, in _ThreadpoolInfo._make_module_from_path(self, filepath) 513 if prefix in self.prefixes or user_api in self.user_api: 514 module_class = globals()[module_class] --> 515 module = module_class(filepath, prefix, user_api, internal_api) 516 self.modules.append(module) File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:606, in _Module.__init__(self, filepath, prefix, user_api, internal_api) 604 self.internal_api = internal_api 605 self._dynlib = ctypes.CDLL(filepath, mode=_RTLD_NOLOAD) --> 606 self.version = self.get_version() 607 self.num_threads = self.get_num_threads() 608 self._get_extra_info() File ~/opt/anaconda3/lib/python3.9/site-packages/threadpoolctl.py:646, in _OpenBLASModule.get_version(self) 643 get_config = getattr(self._dynlib, "openblas_get_config", 644 lambda: None) 645 get_config.restype = ctypes.c_char_p --> 646 config = get_config().split() 647 if config[0] == b"OpenBLAS": 648 return config[1].decode("utf-8") AttributeError: 'NoneType' object has no attribute 'split'

0

watashia0521

Imblearn과 scikit-learn 모두 Version Update 하였으며,  Version은 아래와 같습니다. 아래와 같이 동일한 오류가 발생하고 있습니다. 

 

imbalanced-learn : 0.9.1

scikit-learn : 1.1.2

 

0

권 철민

오류가 smote.fit_resample()에서 발생하나요? 

전체 오류 메시지를 복사해서 여기에 글로 올려 주시겠습니까?

0

권 철민

안녕하십니까,  

아래와 같이 설치를 수행하고 버전을 확인해 보시기 바랍니다. 

pip install -U imbalanced-learn

 

감사합니다. 

모델 서빙과 관련된 강좌가 출시되는지 질문드립니다.

0

24

2

안녕하세요 열심히 수강중인 학생입니다

0

68

2

정수 인덱싱

0

71

2

넘파이 오류

0

88

2

11강 numpy의 axis 축 질문 드립니다.

0

89

2

Kaggle 에서 Santander customer satisfaction data 를 다운로드 되지가 않습니다.

0

80

2

Feature importances 를 보여주는 barplot 이 그래프로 안보여져요.

0

71

2

타이타닉 csv 파일이 주피터 화면에 보이지 않습니다.

0

76

2

타이타닉 csv 파일이 주피터 화면에 보이지 않습니다.

0

65

2

5강 강의 오류가 있어요.

0

86

1

실무에서 LTV 관련 모델 선택 질문입니다!

0

74

2

14강 강의 듣는중에 궁금한게 있어서 질문합니다~

0

70

3

파이썬 다운그레이 후 사이킷런 재설치

0

122

2

좋은 강의 감사합니다.

0

75

2

scoring 함수 음수값

0

68

2

6번 강의에 사이킷런, 파이썬, 아나콘다 각각 버전 일치 안 시키고 진행해도 강의 따라가 지나요?

0

104

2

분류 평가 정확도 예측

0

80

2

안녕하세요. 강의 들으면서 업무에 적용하고 싶은 수강생입니다.

0

100

1

카카오톡 채널 있나요

0

110

1

혹시 강의에서 사용하시는 ppt 받을 수 있는건가요

0

191

2

pca 스케일링 관련하여 질문드립니다.

0

102

2

주피터 대신 구글 코랩

0

174

2

강의에서 사용하는 pdf or ppt자료는 따로 없는 건가요?

0

149

2

실루엣 스코어..

0

87

2