Mercurial > repos > rnateam > graphclust_postprocessing
comparison evaluation.py @ 2:b8e32e577597 draft
planemo upload for repository https://github.com/eteriSokhoyan/galaxytools/tree/branchForIterations/tools/GraphClust/CollectResults commit 9bc3c9b613d106098a78e16534897c88a3738c07
author | rnateam |
---|---|
date | Sat, 24 Dec 2016 18:08:36 -0500 |
parents | ed8c7191b322 |
children | 79b9117aef01 |
comparison
equal
deleted
inserted
replaced
1:ed8c7191b322 | 2:b8e32e577597 |
---|---|
1 import glob | 1 import glob |
2 from os import system | 2 from os import system |
3 import re | 3 import re |
4 from sklearn import metrics | |
4 | 5 |
5 def sh(script): | 6 def sh(script): |
6 system("bash -c '%s'" % script) | 7 system("bash -c '%s'" % script) |
7 | 8 |
8 dataNames = "FASTA/data.names" | 9 dataNames = "FASTA/data.names" |
44 toWrite = "" | 45 toWrite = "" |
45 for i in range(len(listOfClusters)): | 46 for i in range(len(listOfClusters)): |
46 toWrite += listOfClasses[i] + "\t" + listOfClusters[i] + '\n' | 47 toWrite += listOfClasses[i] + "\t" + listOfClusters[i] + '\n' |
47 with open("RESULTS/fullTab.tabular", "w") as full: | 48 with open("RESULTS/fullTab.tabular", "w") as full: |
48 full.write(toWrite) | 49 full.write(toWrite) |
50 | |
51 | |
52 listOfClasses = [] | |
53 listOfClusters = [] | |
54 pattern = re.compile("^RF.*$") | |
55 | |
56 | |
57 if len(listOfClasses) > 0 and pattern.match(str(listOfClasses[0])): | |
58 with open("RESULTS/fullTab.tabular", "r") as tabF: | |
59 for line in tabF.readlines(): | |
60 listOfClasses.append(line.split()[0]) | |
61 listOfClusters.append(line.split()[1]) | |
62 | |
63 completeness_score = metrics.completeness_score(listOfClasses, listOfClusters) | |
64 homogeneity_score = metrics.homogeneity_score(listOfClasses, listOfClusters) | |
65 adjusted_rand_score = metrics.adjusted_rand_score(listOfClasses, listOfClusters) | |
66 adjusted_mutual_info_score = metrics.adjusted_mutual_info_score(listOfClasses, listOfClusters) | |
67 v_measure_score = metrics.v_measure_score(listOfClasses, listOfClusters) | |
68 | |
69 toWrite = "completeness_score : " + str(completeness_score) + "\n" + "homogeneity_score : " + str(homogeneity_score) + "\n" + "adjusted_rand_score : " +str(adjusted_rand_score) + "\n" + "adjusted_mutual_info_score : " + str(adjusted_mutual_info_score)+ "\n" + "v_measure_score : " + str(v_measure_score) | |
70 | |
71 else: | |
72 toWrite = "completeness_score : NA \nhomogeneity_score : NA \nadjusted_rand_score : NA \nadjusted_mutual_info_score : NA \nv_measure_score : NA" | |
73 | |
74 with open("RESULTS/evaluation.txt", "w") as fOut: | |
75 fOut.write(toWrite) |