Skip to content

Commit

Permalink
test_k_means.py
Browse files Browse the repository at this point in the history
  • Loading branch information
liusjchn committed Jun 14, 2018
1 parent d58480d commit 50b872f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test_k_means.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import matplotlib.pyplot as plt
import numpy as np
points = []
for i in range(100):
points.append([np.random.randint(100), np.random.randint(100)])
plt.figure('data', figsize = (8, 8))
result = k_means(points, 4)
for kind, point in result:
if kind == 0:
plt.plot(point[0], point[1], '.', color = "blue")
elif kind == 1:
plt.plot(point[0], point[1], '*', color = "red")
elif kind == 2:
plt.plot(point[0], point[1], '.', color = "black")
elif kind == 3:
plt.plot(point[0], point[1], '*', color = "green")
plt.show()

0 comments on commit 50b872f

Please sign in to comment.