Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.measure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.measure
Commits
eef7238c
Commit
eef7238c
authored
3 years ago
by
Antonio MORAIS
Browse files
Options
Downloads
Patches
Plain Diff
dependent samples
parent
d5e06f87
No related branches found
No related tags found
No related merge requests found
Pipeline
#58305
failed
3 years ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/measure/dependent_samples_generation.py
+30
-21
30 additions, 21 deletions
bob/measure/dependent_samples_generation.py
with
30 additions
and
21 deletions
bob/measure/dependent_samples_generation.py
+
30
−
21
View file @
eef7238c
...
@@ -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
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment