Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autosimilarity_segmentation
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
MARMORET Axel
autosimilarity_segmentation
Commits
1cf2e96e
Commit
1cf2e96e
authored
9 months ago
by
MARMORET Axel
Browse files
Options
Downloads
Patches
Plain Diff
Minor modif: code which is useful to display results.
parent
a506dd44
Branches
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
as_seg/scripts/display_results.py
+45
-0
45 additions, 0 deletions
as_seg/scripts/display_results.py
with
45 additions
and
0 deletions
as_seg/scripts/display_results.py
0 → 100755
+
45
−
0
View file @
1cf2e96e
"""
Script to display experimental results in a nice format.
I should probably use scikit-learn
'
s GridSearchCV, TODO.
"""
import
pandas
as
pd
from
IPython.display
import
display
import
numpy
as
np
import
itertools
def
display_experimental_results
(
data
,
conditions
,
metrics
,
emphasis
=
None
):
assert
data
.
shape
[
-
1
]
==
len
(
metrics
),
f
"
Wrong number of metrics:
{
data
.
shape
[
-
1
]
}
!=
{
len
(
metrics
)
}
"
if
type
(
conditions
)
==
list
:
conditions
=
np
.
array
(
conditions
,
dtype
=
object
)
if
len
(
conditions
.
shape
)
==
1
and
type
(
conditions
[
0
])
not
in
[
list
,
tuple
,
np
.
ndarray
]:
indexes
=
conditions
elif
len
(
conditions
.
shape
)
>
1
or
(
len
(
conditions
.
shape
)
==
1
and
type
(
conditions
)
in
[
list
,
tuple
,
np
.
ndarray
]):
indexes
=
np
.
array
(
list
(
itertools
.
product
(
*
conditions
)))
# cartesian_product
else
:
raise
NotImplementedError
(
f
"
Wrong format of conditions:
{
conditions
}
"
)
dataframe
=
pd
.
DataFrame
(
data
,
columns
=
metrics
,
index
=
indexes
)
if
emphasis
is
not
None
:
display
(
dataframe
.
style
.
bar
(
subset
=
emphasis
,
color
=
'
#5fba7d
'
))
else
:
display
(
dataframe
)
def
find_best_condition
(
data
,
conditions
):
if
type
(
conditions
)
==
list
:
conditions
=
np
.
array
(
conditions
,
dtype
=
object
)
if
len
(
conditions
.
shape
)
==
1
and
type
(
conditions
[
0
])
not
in
[
list
,
tuple
,
np
.
ndarray
]:
best_arg
=
np
.
argmax
(
data
)
best_val
=
conditions
[
best_arg
]
return
best_val
elif
len
(
conditions
.
shape
)
>
1
or
(
len
(
conditions
.
shape
)
==
1
and
type
(
conditions
)
in
[
list
,
tuple
,
np
.
ndarray
]):
best_arg_flatten
=
np
.
argmax
(
data
)
best_arg_tuple
=
np
.
unravel_index
(
best_arg_flatten
,
data
.
shape
)
best_vals
=
[]
for
idx
,
best_arg
in
enumerate
(
best_arg_tuple
):
best_vals
.
append
(
conditions
[
idx
][
best_arg
])
return
np
.
array
(
best_vals
)
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