MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / main

Function main

unsupervised_class/choose_k.py:15–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15def main():
16 X = get_simple_data()
17
18 plt.scatter(X[:,0], X[:,1])
19 plt.show()
20
21 costs = np.empty(10)
22 costs[0] = None
23 for k in range(1, 10):
24 M, R = plot_k_means(X, k, show_plots=False)
25 c = cost(X, R, M)
26 costs[k] = c
27
28 plt.plot(costs)
29 plt.title("Cost vs K")
30 plt.show()
31
32
33if __name__ == '__main__':

Callers 1

choose_k.pyFile · 0.70

Calls 3

get_simple_dataFunction · 0.90
plot_k_meansFunction · 0.90
costFunction · 0.90

Tested by

no test coverage detected