IndentationError expected an indented block while executing elbow method

0 votes

K = range(1,10)
sum_sq_dst = []

for k in K:
km = KMeans(n_clusters=k)
km = km.fit(normalized_data)

sum_sq_dst.append(km.inertia_)

plt.plot(K, sum_sq_dst, 'bx-')
plt.xlabel('No of Clusters')
plt.ylabel('Sum of squared distances')
plt.title('Elbow method for optimal K')
plt.show()

File "<ipython-input-85-2144fb2c9c87>", line 5
    km = KMeans(n_clusters=k)
    ^
IndentationError: expected an indented block
Sep 1, 2021 in Python by Edureka

edited 4 days ago 6 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP