Skip to content
Snippets Groups Projects
Commit eef7238c authored by Antonio MORAIS's avatar Antonio MORAIS
Browse files

dependent samples

parent d5e06f87
No related branches found
No related tags found
No related merge requests found
Pipeline #58305 failed
...@@ -19,28 +19,37 @@ def generate_groundtruth(first_sample_pb, keep_state_pb, nb_samples): ...@@ -19,28 +19,37 @@ def generate_groundtruth(first_sample_pb, keep_state_pb, nb_samples):
def generate_ml(accuracy, groundtruth, nb_systems): def generate_ml(accuracy, groundtruth, nb_systems):
ml = np.zeros([nb_systems, groundtruth.size]) ml = np.zeros([nb_systems, groundtruth.size])
for system in range(nb_systems): for system in range(nb_systems):
print(system) # if (system % (nb_systems/10) == 0):
# print progress each 10 percent
# print((system / nb_systems) * 100, 'percent')
for i in range(groundtruth.size): for i in range(groundtruth.size):
ml[system][i] = np.random.choice([groundtruth[i] ,1 - groundtruth[i]], p=[accuracy, 1 - accuracy]) ml[system][i] = np.random.choice([groundtruth[i] ,1 - groundtruth[i]], p=[accuracy, 1 - accuracy])
return ml return ml
def compute_accuracy(ml, gt): def compute_accuracy_k(ml, gt):
return np.mean(ml == gt, axis=1) return (ml == gt).sum(axis = 1)
for dependency_prob in np.linspace(0.1, 1, 9, endpoint=False):
gt = generate_groundtruth(1, 1, 10000) # print("===== Dependency probability is ", "{:.1f}".format(dependency_prob), "=====")
ml = generate_ml(0.5, gt, 10000) gt = generate_groundtruth(0.5, dependency_prob, 1000)
acc = compute_accuracy(ml, gt) for accuracy in np.linspace(0.1, 1, 9, endpoint=False):
# print("== Accuracy is ", "{:.1f}".format(accuracy), "==")
ml = generate_ml(accuracy, gt, 10000)
fig, ax = plt.subplots(nrows=2, ncols=2, tight_layout=True) acc = compute_accuracy_k(ml, gt)
n_bins = 10 fig, ax = plt.subplots(nrows=2, ncols=2, tight_layout=True)
ax[0,0].hist(acc, bins=n_bins) fig.suptitle('Dependency probability : ' + "{:.1f}".format(dependency_prob) + 'Accuracy : ' + "{:.1f}".format(accuracy), fontsize=16)
n_bins = 20 n_bins = 10
ax[0,1].hist(acc, bins=n_bins) ax[0,0].hist(acc, bins=n_bins)
n_bins = 50 ax[0,0].set_title(str(n_bins) + ' bins')
ax[1,0].hist(acc, bins=n_bins) n_bins = 20
n_bins = 100 ax[0,1].hist(acc, bins=n_bins)
ax[1,1].hist(acc, bins=n_bins) ax[0,1].set_title(str(n_bins) + ' bins')
plt.show() n_bins = 50
\ No newline at end of file ax[1,0].hist(acc, bins=n_bins)
ax[1,0].set_title(str(n_bins) + ' bins')
n_bins = 100
ax[1,1].hist(acc, bins=n_bins)
ax[1,1].set_title(str(n_bins) + ' bins')
plt.savefig('/idiap/home/amorais/Desktop/Dependent_samples_figures/' + 'Depprob' + "{:.1f}".format(dependency_prob) + 'acc' + "{:.1f}".format(accuracy) + '.png')
plt.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment