한량처럼 살고 싶다

[오류 기록]kmeans.fit_predict nonetype object has no attribute 'split' 해결하기 본문

빅데이터 분석

[오류 기록]kmeans.fit_predict nonetype object has no attribute 'split' 해결하기

투영 2023. 4. 27. 10:31

k-means 클러스터링을 하다 발생한 오류였다.

 

아래와 같이 정상적으로 라이브러리를 import 하였다.

from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score, silhouette_samples

 

이후 정규분포로 스케일링을 하고 predict를 하면 이상한 오류가 난다.

from sklearn.preprocessing import StandardScaler
X_features_scaled = StandardScaler().fit_transform(X_features)

kmeans = KMeans(n_clusters=3, random_state=0)
Y_labels = kmeans.fit_predict(X_features_scaled) #오류발생
print (Y_labels)

 

kmeans.fit_predict nonetype object has no attribute 'split'

 

아래 코드를 프롬프트나 셀에 적은 뒤 jupyter는 커널을 restart 해주면 된다. (다른 툴도 껐다가 다시 켜면 반영 되어 있다)

!pip install -U threadpoolctl