Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FreeForestML
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CERN
fsauerbu
FreeForestML
Commits
e83a812c
Unverified
Commit
e83a812c
authored
5 years ago
by
Frank Sauerburger
Browse files
Options
Downloads
Plain Diff
Merge branch '18-rotate-confusion-matrix'
parents
e698251f
c1541045
No related branches found
Branches containing commit
No related tags found
1 merge request
!27
Resolve "Rotate confusion matrix"
Pipeline
#12498
passed
5 years ago
Changes
2
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ConfusionMatrix.ipynb
+67
-46
67 additions, 46 deletions
ConfusionMatrix.ipynb
nnfwtbn/plot.py
+19
-1
19 additions, 1 deletion
nnfwtbn/plot.py
with
86 additions
and
47 deletions
ConfusionMatrix.ipynb
+
67
−
46
View file @
e83a812c
This diff is collapsed.
Click to expand it.
nnfwtbn/plot.py
+
19
−
1
View file @
e83a812c
...
...
@@ -493,7 +493,8 @@ def hist(dataframe, variable, bins, stacks, selection=None,
return
figure
,
axes
def
confusion_matrix
(
df
,
x_processes
,
y_processes
,
x_label
,
y_label
,
weight
=
None
,
axes
=
None
,
figure
=
None
,
**
kwds
):
weight
=
None
,
axes
=
None
,
figure
=
None
,
normalize_rows
=
False
,
**
kwds
):
"""
Creates a confusion matrix.
"""
...
...
@@ -510,6 +511,11 @@ def confusion_matrix(df, x_processes, y_processes, x_label, y_label,
axes
=
figure
.
subplots
()
y_processes
.
reverse
()
if
normalize_rows
:
# Swap processes
y_processes
,
x_processes
=
x_processes
,
y_processes
data
=
np
.
zeros
((
len
(
y_processes
),
len
(
x_processes
)))
for
i_x
,
x_process
in
enumerate
(
x_processes
):
x_df
=
x_process
(
df
)
...
...
@@ -518,14 +524,26 @@ def confusion_matrix(df, x_processes, y_processes, x_label, y_label,
x_y_df
=
y_process
(
x_df
)
data
[
i_y
][
i_x
]
=
weight
(
x_y_df
).
sum
()
/
total_weight
if
normalize_rows
:
# Swap processes back
y_processes
,
x_processes
=
x_processes
,
y_processes
data
=
data
.
T
data
=
pd
.
DataFrame
(
data
,
columns
=
[
p
.
label
for
p
in
x_processes
],
index
=
[
p
.
label
for
p
in
y_processes
])
if
normalize_rows
:
# Swap labels
y_label
,
x_label
=
x_label
,
y_label
sns
.
heatmap
(
data
,
**
dict
(
vmin
=
0
,
vmax
=
1
,
cmap
=
"
Greens
"
,
ax
=
axes
,
cbar_kws
=
{
'
label
'
:
"
$P($%s$|$%s$)$
"
%
(
y_label
,
x_label
)
}
),
**
kwds
)
if
normalize_rows
:
# Swap labels back
y_label
,
x_label
=
x_label
,
y_label
axes
.
set_xlabel
(
x_label
)
axes
.
set_ylabel
(
y_label
)
axes
.
set_ylim
(
len
(
y_processes
),
0
)
...
...
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