''function' object has no attribute 'inertia_'
here is the part of the code where the error occurs:
k = 2
K = range(1, len(dist) +1)
models = [KMeans(n_clusters = k, random_state=42).fit]
dist = [model.inertia_ for model in models]
plt.plot(K, dist, marker='+')
plt.show
I get this payment message:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-44-cb9780180c3e> in <module>()
1 models = [KMeans(n_clusters = k, random_state=42).fit]
----> 2 dist = [model.inertia_ for model in models]
3
4 plt.plot(K, dist, marker='+')
5 plt.show
<ipython-input-44-cb9780180c3e> in <listcomp>(.0)
1 models = [KMeans(n_clusters = k, random_state=42).fit]
----> 2 dist = [model.inertia_ for model in models]
3
4 plt.plot(K, dist, marker='+')
5 plt.show
AttributeError: 'function' object has no attribute 'inertia_'
I also don't understand what exactly is considered a "function" object
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
