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

Function main

unsupervised_class/kmeans.py:108–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106
107
108def main():
109 X = get_simple_data()
110
111 # what does it look like without clustering?
112 plt.scatter(X[:,0], X[:,1])
113 plt.show()
114
115 K = 3 # luckily, we already know this
116 plot_k_means(X, K, beta=1.0, show_plots=True)
117
118 K = 3 # luckily, we already know this
119 plot_k_means(X, K, beta=3.0, show_plots=True)
120
121 K = 3 # luckily, we already know this
122 plot_k_means(X, K, beta=10.0, show_plots=True)
123
124 K = 5 # what happens if we choose a "bad" K?
125 plot_k_means(X, K, max_iter=30, show_plots=True)
126
127 K = 5 # what happens if we change beta?
128 plot_k_means(X, K, max_iter=30, beta=0.3, show_plots=True)
129
130
131if __name__ == '__main__':

Callers 1

kmeans.pyFile · 0.70

Calls 2

get_simple_dataFunction · 0.85
plot_k_meansFunction · 0.70

Tested by

no test coverage detected