Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
baseLess
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
Lannoy, Carlos de
baseLess
Commits
841ebff8
Commit
841ebff8
authored
3 years ago
by
Noordijk, Ben
Browse files
Options
Downloads
Patches
Plain Diff
Save confusion matrix plots
parent
cb35d96e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
compare_benchmark_performance/compare_accuracy.py
+12
-7
12 additions, 7 deletions
compare_benchmark_performance/compare_accuracy.py
with
12 additions
and
7 deletions
compare_benchmark_performance/compare_accuracy.py
+
12
−
7
View file @
841ebff8
...
...
@@ -2,9 +2,10 @@ import argparse
from
pathlib
import
Path
from
itertools
import
chain
from
multiprocessing
import
Pool
import
pickle
import
pandas
as
pd
from
sklearn.metrics
import
confusion_matrix
,
f1_score
,
accuracy_score
from
sklearn.metrics
import
confusion_matrix
,
ConfusionMatrixDisplay
,
f1_score
,
accuracy_score
import
matplotlib.pyplot
as
plt
import
seaborn
as
sns
import
numpy
as
np
...
...
@@ -154,7 +155,7 @@ def parse_squigglenet_output(in_dir, ground_truth):
y_flipped
=
1
-
y_pred
f1
=
f1_score
(
y_true
,
y_flipped
)
accuracy
=
accuracy_score
(
y_true
,
y_flipped
)
cm
=
confusion_matrix
(
y_true
,
y_p
r
ed
)
cm
=
confusion_matrix
(
y_true
,
y_
flip
ped
)
return
tool
,
target_species
,
fold
,
accuracy
,
f1
,
cm
...
...
@@ -203,11 +204,15 @@ def main(args):
# Create confusion matrices
cm_series
=
df
.
groupby
([
'
tool
'
,
'
species
'
])[
'
confusion matrix
'
].
aggregate
(
np
.
sum
)
# TODO save to file here
for
tool
,
dataframe
in
cm_series
.
groupby
(
level
=
0
):
print
(
tool
)
print
(
dataframe
)
with
open
(
args
.
out_dir
/
f
'
confusion_matrices.pickle
'
,
'
wb
'
)
as
f
:
pickle
.
dump
(
cm_series
,
f
)
# Confusion matrix out directory
cm_out_dir
=
args
.
out_dir
/
'
confusion_matrices
'
cm_out_dir
.
mkdir
(
exist_ok
=
True
)
for
(
tool
,
species
),
cm
in
cm_series
.
iteritems
():
ConfusionMatrixDisplay
(
cm
).
plot
()
plt
.
savefig
(
cm_out_dir
/
f
'
{
tool
}
_
{
species
}
.png
'
)
filename
=
'
all_algorithms_performance
'
...
...
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