Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dc decision criteria fixed
  • Loading branch information
kbudhath committed Feb 14, 2017
1 parent eace075 commit ee3f344
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions test_synthetic.py
Expand Up @@ -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]))
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -443,6 +443,7 @@ def test_power():


if __name__ == "__main__":
test_power()
test_decision_rate()
# test_power()
# test_runtime()
# _decision_rate("multinomial")

0 comments on commit ee3f344

Please sign in to comment.