K-Prototypes clustering — for when you’re clustering dynamic, real world data

cluster analysis 101
partial head of the data frame
value counts
Green denotes a match to the ‘Mode’ row
costs = []
n_clusters = []
cat_cols = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14]for i in tqdm(range(2, 10)):
try:
kproto = KPrototypes(n_clusters=i, init='Huang', verbose=2)
clusters = kproto.fit_predict(data_corr, categorical=cat_cols)
costs.append(kproto.cost_)
n_clusters.append(i)
except:
print(f"Can't cluster with {i} clusters")
fig = go.Figure(data=go.Scatter(x=n_clusters, y=costs))
fig.show()
Elbow plot
Clusters with K-Prototypes (categorical Modes and continuous Means)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store