K для кластеризации - Как преобразовать строку в число с плавающей точкой - PullRequest
0 голосов
/ 29 апреля 2020
from sklearn.cluster import KMeans
from matplotlib import pyplot as plt,

distorsions = []
for k in range(1, 10)

kmeans = KMeans(init="k-means++", 
                n_clusters=k, 
                random_state=0, 
                n_init = 12, 
                max_iter=300,
                tol=0.00001)
kmeans.fit(df1)

distorsions.append(kmeans.inertia_)

fig, ax = subplots(figsize=(8, 4))
ax.plot(range(1, 10), distorsions,'--bo')
ax.set_xlabel('Poverty Household', fontsize=12)
ax.set_ylabel('Communnity Area', fontsize=12)

plt.grid(True)
plt.title('K-Means Elbow curve', fontsize=18)
plt.tight_layout()
plt.legend()
plt.show()

Сообщение об ошибке, показывающее: ValueError: не удалось преобразовать строку в число с плавающей точкой: 'Norwood Park'

enter image description here

...