Commit ca0fcf2c3f1b1faa7cdef49e229d135c891176c6
1 parent
0b30718782
Exists in
master
Adapting the script to my library. Need to work again
Showing 1 changed file with 17 additions and 12 deletions Side-by-side Diff
bin/plot_clusters.py
... | ... | @@ -55,8 +55,8 @@ |
55 | 55 | |
56 | 56 | |
57 | 57 | |
58 | +from data import read_file, index_by_id | |
58 | 59 | |
59 | - | |
60 | 60 | # Defining argparse |
61 | 61 | parser = argparse.ArgumentParser(prog='Plotter', description='Plot a file of 2d ou 3d dimension') |
62 | 62 | parser.add_argument('clusterfile', type=str, |
... | ... | @@ -66,8 +66,6 @@ |
66 | 66 | parser.add_argument('-o-', '--output', type=str, |
67 | 67 | default='plot.pdf', |
68 | 68 | help='the path of the ploted file') |
69 | -parser.add_argument('-t', '--toy', action='store_true', | |
70 | - help='test the script on a toy example. Do not test all the file content') | |
71 | 69 | |
72 | 70 | args = parser.parse_args() |
73 | 71 | |
74 | 72 | |
75 | 73 | |
... | ... | @@ -75,12 +73,24 @@ |
75 | 73 | CLUSTERFILE_PATH=args.clusterfile |
76 | 74 | VECTORFILE_PATH=args.vectorfile |
77 | 75 | OUTFILE_PATH = args.output |
78 | -TOY_VERSION = args.toy | |
79 | 76 | |
80 | -if check_files(VECTORFILE_PATH, CLUSTERFILE_PATH) == False: | |
81 | - print("Les fichiers ne sont pas dans le meme ordre. Dans une version futur, cela générera une exception. On stop le processus.") | |
82 | - exit(1) | |
77 | +data_vector = read_file(VECTORFILE_PATH) | |
78 | +features = np.asarray([x[1] for x in data_vector]) | |
79 | +features_T = np.transpose(features) | |
83 | 80 | |
81 | +data_cluster = read_file(CLUSTERFILE_PATH) | |
82 | +data_cluster_ind = index_by_id(data_cluster) | |
83 | +clusters = [data_cluster_ind[x[0][0]][x[0][3]][0][1] for x in data_vector] | |
84 | + | |
85 | + | |
86 | +# TODO: compute tsne file | |
87 | +# TODO: adapt the script for the new library | |
88 | +df = pd.DataFrame(dict( | |
89 | + x=features_T[0], | |
90 | + y=features_T[1], | |
91 | + cluster=np.transpose(clusters)[0] | |
92 | + )) | |
93 | +exit(1) | |
84 | 94 | # Get Vectors |
85 | 95 | metas, vectors = read_vector_file(VECTORFILE_PATH, toy_version = TOY_VERSION) |
86 | 96 | vectors_T = np.transpose(vectors) |
... | ... | @@ -90,11 +100,6 @@ |
90 | 100 | |
91 | 101 | #print(np.transpose(clusters)[0]) |
92 | 102 | #print(np.transpose(metas)[0]) |
93 | -df = pd.DataFrame(dict( | |
94 | - x=vectors_T[0], | |
95 | - y=vectors_T[1], | |
96 | - cluster=np.transpose(clusters)[0] | |
97 | - )) | |
98 | 103 | |
99 | 104 | groups = df.groupby('cluster') |
100 | 105 |