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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
//
// testclustercalcs.cpp
// Mothur
//
// Created by Sarah Westcott on 4/18/17.
// Copyright © 2017 Schloss Lab. All rights reserved.
//
#include "testclustercalcs.hpp"
#include "mcc.hpp"
/**************************************************************************************************/
TestClusterCalcs::TestClusterCalcs(string metricName) { //setup
if (metricName == "mcc") { metric = new MCC(); }
else if (metricName == "sens") { metric = new Sensitivity(); }
else if (metricName == "spec") { metric = new Specificity(); }
else if (metricName == "tptn") { metric = new TPTN(); }
else if (metricName == "tp") { metric = new TP(); }
else if (metricName == "tn") { metric = new TN(); }
else if (metricName == "fp") { metric = new FP(); }
else if (metricName == "fn") { metric = new FN(); }
else if (metricName == "f1score") { metric = new F1Score(); }
else if (metricName == "accuracy") { metric = new Accuracy(); }
else if (metricName == "ppv") { metric = new PPV(); }
else if (metricName == "npv") { metric = new NPV(); }
else if (metricName == "fdr") { metric = new FDR(); }
else if (metricName == "fpfn") { metric = new FPFN(); }
}
/**************************************************************************************************/
TestClusterCalcs::~TestClusterCalcs() { delete metric; }
/**************************************************************************************************/
TEST(Test_Calc_ClusterCalcs, mcc) {
TestClusterCalcs test("mcc");
double result = test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn);
ASSERT_NEAR(0.791646, result, 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, sens) {
TestClusterCalcs test("sens");
ASSERT_NEAR(0.699235, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, spec) {
TestClusterCalcs test("spec");
ASSERT_NEAR(0.999951, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, tptn) {
TestClusterCalcs test("tptn");
ASSERT_NEAR(0.9997691, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, tp) {
TestClusterCalcs test("tp");
ASSERT_NEAR(0.000423, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, tn) {
TestClusterCalcs test("tn");
ASSERT_NEAR(0.9993461, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, fp) {
TestClusterCalcs test("fp");
ASSERT_NEAR(0.999951, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, fn) {
TestClusterCalcs test("fn");
ASSERT_NEAR(0.999818, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, f1score) {
TestClusterCalcs test("f1score");
ASSERT_NEAR(0.7856801, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, accuracy) {
TestClusterCalcs test("accuracy");
ASSERT_NEAR(0.999769, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, ppv) {
TestClusterCalcs test("ppv");
ASSERT_NEAR(0.896514, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, npv) {
TestClusterCalcs test("npv");
ASSERT_NEAR(0.9998179, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, fdr) {
TestClusterCalcs test("fdr");
ASSERT_NEAR(0.896514, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
TEST(Test_Calc_ClusterCalcs, fpfn) {
TestClusterCalcs test("fpfn");
ASSERT_NEAR(0.999769, test.metric->getValue(test.fake.tp,test.fake.tn,test.fake.fp,test.fake.fn), 0.0001); //metric value
}
/**************************************************************************************************/
|