comparison evaluation.py @ 2:6c88ad83de28 draft

planemo upload for repository https://github.com/eteriSokhoyan/galaxytools/tree/branchForIterations/tools/GraphClust/CollectResults commit 287021573c592fdb70fdbbc88943aa16a8740fc0
author rnateam
date Fri, 13 Jan 2017 16:57:54 -0500
parents e166d1382033
children a8fde40f00fc
comparison
equal deleted inserted replaced
1:e166d1382033 2:6c88ad83de28
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 pattern = re.compile("^RF.*$")
53
54
55 if len(listOfClasses) > 0 and pattern.match(str(listOfClasses[0])):
56
57 completeness_score = metrics.completeness_score(listOfClasses, listOfClusters)
58 homogeneity_score = metrics.homogeneity_score(listOfClasses, listOfClusters)
59 adjusted_rand_score = metrics.adjusted_rand_score(listOfClasses, listOfClusters)
60 adjusted_mutual_info_score = metrics.adjusted_mutual_info_score(listOfClasses, listOfClusters)
61 v_measure_score = metrics.v_measure_score(listOfClasses, listOfClusters)
62
63 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)
64
65 else:
66 toWrite = "completeness_score : NA \nhomogeneity_score : NA \nadjusted_rand_score : NA \nadjusted_mutual_info_score : NA \nv_measure_score : NA"
67
68 with open("RESULTS/evaluation.txt", "w") as fOut:
69 fOut.write(toWrite)