From ee3f3446cf94c2808337af0e1380147c686ec9ba Mon Sep 17 00:00:00 2001 From: Kailash Budhathoki Date: Tue, 14 Feb 2017 19:29:48 +0100 Subject: [PATCH] dc decision criteria fixed --- test_synthetic.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/test_synthetic.py b/test_synthetic.py index 9fdc38a..c15bd90 100644 --- a/test_synthetic.py +++ b/test_synthetic.py @@ -132,7 +132,7 @@ def _decision_rate(srcX): if undecided_dc: res_dc.append(random.choice([True, False])) else: - res_dc.append(dc_score[0] > dc_score[1]) + res_dc.append(dc_score[0] < dc_score[1]) if undecided_dr: res_dr.append(random.choice([True, False])) @@ -165,17 +165,17 @@ def _decision_rate(srcX): acc_cisc.append(acc_cisc_r) acc_dc.append(acc_dc_r) acc_dr.append(acc_dr_r) - print dec_rate - print acc_dc - print acc_dr - print acc_cisc + # print dec_rate + # print acc_dc + # print acc_dr + # print acc_cisc - with open("results/dec_rate_synth_data.dat", "w") as writer: + with open("results/dec_rate_synth_%s.dat" % srcX, "w") as writer: for i, r in enumerate(dec_rate): writer.write("%.2f %.2f %.2f %.2f\n" % (r, acc_dc[i], acc_dr[i], acc_cisc[i])) - plot_multiline([acc_cisc, acc_dc, acc_dr], dec_rate, [ - "CISC", "DC", "DR"], "decision rate", "accuracy", "decision rate versus accuracy", "dec_rate_%sX.png" % srcX) + # plot_multiline([acc_cisc, acc_dc, acc_dr], dec_rate, [ + # "CISC", "DC", "DR"], "decision rate", "accuracy", "decision rate versus accuracy", "dec_rate_%sX.png" % srcX) def test_accuracy(): @@ -204,7 +204,7 @@ def test_accuracy(): dr_score = dr(X, Y, level) ncorrect_cisc += int(cisc_score[0] < cisc_score[1]) - ncorrect_dc += int(dc_score[0] > dc_score[1]) + ncorrect_dc += int(dc_score[0] < dc_score[1]) ncorrect_dr += int(dr_score[0] > level and dr_score[1] < level) print "%18s%10.2f%10.2f%10.2f" % (srcX, ncorrect_dc / nsim, ncorrect_dr / nsim, ncorrect_cisc / nsim) @@ -252,8 +252,8 @@ def test_accuracy_at_model_space(): rsc_sc.nwrong += int(cisc_score[0] > cisc_score[1]) rsc_sc.nundec += int(cisc_score[0] == cisc_score[1]) - rsc_dc.ncorrect += int(dc_score[0] > dc_score[1]) - rsc_dc.nwrong += int(dc_score[0] < dc_score[1]) + rsc_dc.ncorrect += int(dc_score[0] < dc_score[1]) + rsc_dc.nwrong += int(dc_score[0] > dc_score[1]) rsc_dc.nundec += int(dc_score[0] == dc_score[1]) rsc_dr.ncorrect += int(dr_score[0] @@ -268,8 +268,8 @@ def test_accuracy_at_model_space(): ranm_sc.nwrong += int(cisc_score[0] > cisc_score[1]) ranm_sc.nundec += int(cisc_score[0] == cisc_score[1]) - ranm_dc.ncorrect += int(dc_score[0] > dc_score[1]) - ranm_dc.nwrong += int(dc_score[0] < dc_score[1]) + ranm_dc.ncorrect += int(dc_score[0] < dc_score[1]) + ranm_dc.nwrong += int(dc_score[0] > dc_score[1]) ranm_dc.nundec += int(dc_score[0] == dc_score[1]) ranm_dr.ncorrect += int(dr_score[0] @@ -283,8 +283,8 @@ def test_accuracy_at_model_space(): rall_sc.nwrong += int(cisc_score[0] > cisc_score[1]) rall_sc.nundec += int(cisc_score[0] == cisc_score[1]) - rall_dc.ncorrect += int(dc_score[0] > dc_score[1]) - rall_dc.nwrong += int(dc_score[0] < dc_score[1]) + rall_dc.ncorrect += int(dc_score[0] < dc_score[1]) + rall_dc.nwrong += int(dc_score[0] > dc_score[1]) rall_dc.nundec += int(dc_score[0] == dc_score[1]) rall_dr.ncorrect += int(dr_score[0] @@ -335,9 +335,9 @@ def test_accuracy_with_nonparam_tests(): else: nind_this += 1 - if dc_score[0] > dc_score[1]: + if dc_score[0] < dc_score[1]: ncorrect_dc += 1 - elif dc_score[0] < dc_score[1]: + elif dc_score[0] > dc_score[1]: nwrong_dc += 1 else: nind_dc += 1 @@ -443,6 +443,7 @@ def test_power(): if __name__ == "__main__": - test_power() + test_decision_rate() + # test_power() # test_runtime() # _decision_rate("multinomial")