Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.measure
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.measure
Commits
5e5fd58f
Commit
5e5fd58f
authored
Jun 27, 2018
by
Theophile GENTILHOMME
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[script][figure] Stack dev/eval histo verticaly
parent
b517d9d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
20 deletions
+27
-20
bob/measure/script/figure.py
bob/measure/script/figure.py
+27
-20
No files found.
bob/measure/script/figure.py
View file @
5e5fd58f
...
@@ -669,9 +669,8 @@ class Hist(PlotBase):
...
@@ -669,9 +669,8 @@ class Hist(PlotBase):
if
self
.
_hide_dev
and
not
self
.
_eval
:
if
self
.
_hide_dev
and
not
self
.
_eval
:
raise
click
.
BadParameter
(
raise
click
.
BadParameter
(
"You can only use --hide-dev along with --eval"
)
"You can only use --hide-dev along with --eval"
)
# dev hist are displayed next to eval hist
# dev hist are displayed next to eval hist
self
.
_n
col
s
*=
1
if
self
.
_hide_dev
or
not
self
.
_eval
else
2
self
.
_n
row
s
*=
1
if
self
.
_hide_dev
or
not
self
.
_eval
else
2
self
.
_nlegends
=
ctx
.
meta
.
get
(
'legends_ncol'
,
3
)
self
.
_nlegends
=
ctx
.
meta
.
get
(
'legends_ncol'
,
3
)
self
.
_legend_loc
=
self
.
_legend_loc
or
'upper center'
self
.
_legend_loc
=
self
.
_legend_loc
or
'upper center'
# number of subplot on one page
# number of subplot on one page
...
@@ -681,29 +680,31 @@ class Hist(PlotBase):
...
@@ -681,29 +680,31 @@ class Hist(PlotBase):
self
.
_x_label
=
'Score values'
self
.
_x_label
=
'Score values'
self
.
_end_setup_plot
=
False
self
.
_end_setup_plot
=
False
# overide _titles of PlotBase
# overide _titles of PlotBase
self
.
_titles
=
ctx
.
meta
.
get
(
'titles'
)
self
.
_titles
=
ctx
.
meta
.
get
(
'titles'
,
[])
*
2
if
self
.
_titles
is
not
None
and
len
(
self
.
_titles
)
==
self
.
n_systems
\
and
not
self
.
_hide_dev
:
# use same legend for dev and eval if needed
self
.
_titles
=
[
x
for
pair
in
zip
(
self
.
_titles
,
self
.
_titles
)
for
x
in
pair
]
def
compute
(
self
,
idx
,
input_scores
,
input_names
):
def
compute
(
self
,
idx
,
input_scores
,
input_names
):
''' Draw histograms of negative and positive scores.'''
''' Draw histograms of negative and positive scores.'''
dev_neg
,
dev_pos
,
eval_neg
,
eval_pos
,
threshold
=
\
dev_neg
,
dev_pos
,
eval_neg
,
eval_pos
,
threshold
=
\
self
.
_get_neg_pos_thres
(
idx
,
input_scores
,
input_names
)
self
.
_get_neg_pos_thres
(
idx
,
input_scores
,
input_names
)
idx
*=
1
if
self
.
_hide_dev
or
not
self
.
_eval
else
2
# keep id of the current system
sys
=
idx
# if the id of the current system does not match the id of the plot,
# change it
if
not
self
.
_hide_dev
and
self
.
_eval
:
row
=
int
(
idx
/
self
.
_ncols
)
*
2
col
=
idx
%
self
.
_ncols
idx
=
col
+
self
.
_ncols
*
row
if
not
self
.
_hide_dev
or
not
self
.
_eval
:
if
not
self
.
_hide_dev
or
not
self
.
_eval
:
self
.
_print_subplot
(
idx
,
dev_neg
,
dev_pos
,
threshold
,
self
.
_print_subplot
(
idx
,
sys
,
dev_neg
,
dev_pos
,
threshold
,
not
self
.
_no_line
,
False
)
not
self
.
_no_line
,
False
)
idx
+=
1
if
self
.
_eval
and
not
self
.
_hide_dev
else
0
if
self
.
_eval
:
if
self
.
_eval
:
self
.
_print_subplot
(
idx
,
eval_neg
,
eval_pos
,
threshold
,
idx
+=
self
.
_ncols
if
not
self
.
_hide_dev
else
0
self
.
_print_subplot
(
idx
,
sys
,
eval_neg
,
eval_pos
,
threshold
,
not
self
.
_no_line
,
True
)
not
self
.
_no_line
,
True
)
def
_print_subplot
(
self
,
idx
,
neg
,
pos
,
threshold
,
draw_line
,
evaluation
):
def
_print_subplot
(
self
,
idx
,
sys
,
neg
,
pos
,
threshold
,
draw_line
,
evaluation
):
''' print a subplot for the given score and subplot index'''
''' print a subplot for the given score and subplot index'''
n
=
idx
%
self
.
_step_print
n
=
idx
%
self
.
_step_print
col
=
n
%
self
.
_ncols
col
=
n
%
self
.
_ncols
...
@@ -712,16 +713,21 @@ class Hist(PlotBase):
...
@@ -712,16 +713,21 @@ class Hist(PlotBase):
self
.
_setup_hist
(
neg
,
pos
)
self
.
_setup_hist
(
neg
,
pos
)
if
col
==
0
:
if
col
==
0
:
axis
.
set_ylabel
(
self
.
_y_label
)
axis
.
set_ylabel
(
self
.
_y_label
)
# systems per page
sys_per_page
=
self
.
_step_print
/
(
1
if
self
.
_hide_dev
or
not
self
.
_eval
else
2
)
# rest to be printed
# rest to be printed
rest_print
=
self
.
n_systems
*
(
2
if
self
.
_eval
and
not
self
.
_hide_dev
sys_idx
=
sys
%
sys_per_page
else
1
)
-
int
(
idx
/
self
.
_step_print
)
\
rest_print
=
self
.
n_systems
-
int
(
sys
/
sys_per_page
)
*
sys_per_page
*
self
.
_step_print
# lower histo only
if
n
+
self
.
_ncols
>=
min
(
self
.
_step_print
,
rest_print
):
is_lower
=
evaluation
or
not
self
.
_eval
if
is_lower
and
sys_idx
+
self
.
_ncols
>=
min
(
sys_per_page
,
rest_print
):
axis
.
set_xlabel
(
self
.
_x_label
)
axis
.
set_xlabel
(
self
.
_x_label
)
dflt_title
=
"Eval. scores"
if
evaluation
else
"Dev. scores"
dflt_title
=
"Eval. scores"
if
evaluation
else
"Dev. scores"
if
self
.
n_systems
==
1
and
(
not
self
.
_eval
or
self
.
_hide_dev
):
if
self
.
n_systems
==
1
and
(
not
self
.
_eval
or
self
.
_hide_dev
):
dflt_title
=
" "
dflt_title
=
" "
axis
.
set_title
(
self
.
_get_title
(
idx
,
dflt_title
))
add
=
self
.
n_systems
if
is_lower
else
0
axis
.
set_title
(
self
.
_get_title
(
sys
+
add
,
dflt_title
))
label
=
"%s threshold%s"
%
(
label
=
"%s threshold%s"
%
(
''
if
self
.
_criterion
is
None
else
''
if
self
.
_criterion
is
None
else
self
.
_criterion
.
upper
(),
' (dev)'
if
self
.
_eval
else
''
self
.
_criterion
.
upper
(),
' (dev)'
if
self
.
_eval
else
''
...
@@ -729,10 +735,11 @@ class Hist(PlotBase):
...
@@ -729,10 +735,11 @@ class Hist(PlotBase):
if
draw_line
:
if
draw_line
:
self
.
_lines
(
threshold
,
label
,
neg
,
pos
,
idx
)
self
.
_lines
(
threshold
,
label
,
neg
,
pos
,
idx
)
mult
=
2
if
self
.
_eval
and
not
self
.
_hide_dev
else
1
# if it was the last subplot of the page or the last subplot
# if it was the last subplot of the page or the last subplot
# to display, save figure
# to display, save figure
if
self
.
_step_print
==
sub_plot_idx
or
idx
==
self
.
n_systems
*
mult
-
1
:
if
self
.
_step_print
==
sub_plot_idx
or
(
is_lower
and
sys
==
self
.
n_systems
-
1
):
# print legend on the page
# print legend on the page
self
.
plot_legends
()
self
.
plot_legends
()
mpl
.
tight_layout
()
mpl
.
tight_layout
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment