MCPcopy Index your code
hub / github.com/rushter/MLAlgorithms / kmeans_example

Function kmeans_example

examples/kmeans.py:7–17  ·  view source on GitHub ↗
(plot=False)

Source from the content-addressed store, hash-verified

5
6
7def kmeans_example(plot=False):
8 X, y = make_blobs(
9 centers=4, n_samples=500, n_features=2, shuffle=True, random_state=42
10 )
11 clusters = len(np.unique(y))
12 k = KMeans(K=clusters, max_iters=150, init="++")
13 k.fit(X)
14 k.predict()
15
16 if plot:
17 k.plot()
18
19
20if __name__ == "__main__":

Callers 1

kmeans.pyFile · 0.85

Calls 4

plotMethod · 0.95
KMeansClass · 0.90
fitMethod · 0.45
predictMethod · 0.45

Tested by

no test coverage detected