AI·빅데이터 융합 경영학 Study Note

NoneType' object has no attribute 'split' 본문

기타/오류 해결

NoneType' object has no attribute 'split'

SubjectOwner 2023. 11. 9. 16:35
# 각 모델별 prediction 저장 및 성능(Accuracy) 확인
pred_results = []
for clf in clfs :
    pred = clf.fit(X_train, y_train).predict(X_test)
    name = type(clf).__name__
    pred_results.append(pd.Series(pred, name=name))
    print("{:30s} {}".format(name, accuracy_score(y_test, pred)))

 

또는

from sklearn.ensemble import VotingClassifier

# 위에서 평가한 모든 모델을 앙상블할 경우
voting = VotingClassifier(estimators = [(type(clf).__name__, clf) for clf in clfs], voting='hard')
voting.fit(X_train, y_train).score(X_test, y_test)

 

 

오류코드

NoneType' object has no attribute 'split'

 

https://velog.io/@seonydg/scikit-learncluster-KMeans-Nonetype-object-has-no-attribute-split-%EC%98%A4%EB%A5%98

 

scikit-learn,cluster KMeans 'Nonetype' object has no attribute 'split' 오류

scikit-learn이 버전 업그레이드 되면서 군집화 모듈 KMeans를 fit()할 때 오류가 발생한다.scikit-learn을 설치하면 threadpoolctl 모듈도 함께 설치가 되는데 버전으로 인해 호환성에 문제가 생기는 것이다.t

velog.io

pip install threadpoolctl==3.1.0

import threadpoolctl
print('threadpoolctl Version :', threadpoolctl.__version__)

 

이걸 명령프롬프트가 아니라 vs코드에 입력해야 하더라. 그러고 재부팅, 모두실행하면 됨.