def test2(self): """ test RIE """ ratio = float(self.numActives) / self.numMol # best case RIEmax = ((1 - math.exp(-self.alpha*ratio)) / (1 - math.exp(-self.alpha))) / ratio rie = Scoring.CalcRIE(self.scoreBestCase, self.index, self.alpha) self.assertAlmostEqual(rie, RIEmax, self.acc) # worst case RIEmin = ((1 - math.exp(self.alpha*ratio)) / (1 - math.exp(self.alpha))) / ratio rie = Scoring.CalcRIE(self.scoreWorstCase, self.index, self.alpha) self.assertAlmostEqual(rie, RIEmin, self.acc) # empty list self.assertRaises(ValueError, Scoring.CalcRIE, self.scoreEmptyList, self.index, self.alpha) # alpha == 0 self.assertRaises(ValueError, Scoring.CalcRIE, self.scoreBestCase, self.index, 0.0) # all decoys rie = Scoring.CalcRIE(self.scoreAllDecoys, self.index, self.alpha) self.assertEqual(rie, 0.0)
def evaluate(activity_arr): auc = Scoring.CalcAUC(activity_arr, 0) print("AUC: ", auc) ef = Scoring.CalcEnrichment(activity_arr, 0, [0.01]) print("EF for 1%: ", ef[0]) ef = Scoring.CalcEnrichment(activity_arr, 0, [0.05]) print("EF for 5%: ", ef[0]) rie = Scoring.CalcRIE(activity_arr, 0, 100) print("RIE for 100: ", rie) bedroc = Scoring.CalcBEDROC(activity_arr, 0, 100) print("BEDROC for 100: ", bedroc)
def evaluation(activity_arr: list, output_file: str): inputoutput_utils.create_parent_directory(output_file) auc = Scoring.CalcAUC(activity_arr, 0) ef1 = Scoring.CalcEnrichment(activity_arr, 0, [0.01]) ef5 = Scoring.CalcEnrichment(activity_arr, 0, [0.05]) rie = Scoring.CalcRIE(activity_arr, 0, 100) bedroc = Scoring.CalcBEDROC(activity_arr, 0, 100) output = { "AUC": auc, "EF1": ef1[0], "EF5": ef5[0], "RIE": rie, "BEDROC": bedroc } with open(output_file, "w", encoding="utf-8") as stream: json.dump(output, stream)
def evaluation(activity_arr: list, output_file: str): with open(output_file, "w") as stream: auc = Scoring.CalcAUC(activity_arr, 0) stream.write("AUC: ") stream.write(str(auc)) ef = Scoring.CalcEnrichment(activity_arr, 0, [0.01]) stream.write("\nEF for 1%: ") stream.write(str(ef[0])) ef = Scoring.CalcEnrichment(activity_arr, 0, [0.05]) stream.write("\nEF for 5%: ") stream.write(str(ef[0])) rie = Scoring.CalcRIE(activity_arr, 0, 100) stream.write("\nRIE for 100: ") stream.write(str(rie)) bedroc = Scoring.CalcBEDROC(activity_arr, 0, 100) stream.write("\nBEDROC for 100: ") stream.write(str(bedroc))
def calculate(self, score, index): tmp = [] for p in self.params: tmp.append(Scoring.CalcRIE(score, index, p)) return tmp