-
Notifications
You must be signed in to change notification settings - Fork 1
/
cluster_image.py
57 lines (55 loc) · 1.55 KB
/
cluster_image.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# import os
import numpy as np
import matplotlib.pyplot as plt
import random
# cluster_dp_GPU = "./cluster_dp_GPU"
# os.system(cluster_dp_GPU)
input_file = raw_input("enter the input file name:")
result_file = raw_input("enter the result file name:")
location = []
# input_lable = []
for line in open("dataset/"+input_file, "r"):
# line = line.replace('-','')
items = line.strip("\n").split(",")
# input_lable.append(int(items.pop()))
tmp = []
for item in items:
tmp.append(float(item))
location.append(tmp)
location = np.array(location)
# input_lable = np.array(input_lable)
length = len(location)
print "data input complete"
result_lable = []
for line in open(result_file, "r"):
items = line.strip("\n").split(",")
result_lable.append(int(items.pop()))
print "result read complete"
R = range(256)
random.shuffle(R)
random.shuffle(R)
R = np.array(R) / 255.0
G = range(256)
random.shuffle(G)
random.shuffle(G)
G = np.array(G) / 255
B = range(256)
random.shuffle(B)
random.shuffle(B)
B = np.array(B) / 255.0
colors = []
for i in range(256):
colors.append((R[i], G[i], B[i]))
# plt.figure()
# for i in range(length):
# index = input_lable[i]
# plt.plot(location[i][0], location[i][1], color=(R[index*5%255],G[index*15%255],B[index*20%255]), marker='.')
# plt.xlabel('x'), plt.ylabel('y')
# plt.show()
# plt.close()
plt.figure()
for i in range(length):
index = result_lable[i]
plt.plot(location[i][0], location[i][1], color=(R[index*5%255],G[index*15%255],B[index*20%255]), marker='.')
plt.xlabel('x'), plt.ylabel('y')
plt.show()