Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
bioroboticslab
robofish
io
Commits
0156cacc
Commit
0156cacc
authored
3 years ago
by
Andi Gerken
Browse files
Options
Downloads
Patches
Plain Diff
Bugfix in evaluate
parent
e9175f62
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#48754
failed
3 years ago
Stage: package
Stage: test
Stage: deploy
Stage: trigger
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/robofish/evaluate/app.py
+1
-1
1 addition, 1 deletion
src/robofish/evaluate/app.py
src/robofish/evaluate/evaluate.py
+27
-26
27 additions, 26 deletions
src/robofish/evaluate/evaluate.py
src/robofish/io/utils.py
+4
-0
4 additions, 0 deletions
src/robofish/io/utils.py
with
32 additions
and
27 deletions
src/robofish/evaluate/app.py
+
1
−
1
View file @
0156cacc
...
@@ -98,7 +98,7 @@ def evaluate(args=None):
...
@@ -98,7 +98,7 @@ def evaluate(args=None):
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
analysis_type
==
"
all
"
and
args
.
save_path
is
None
:
if
args
.
analysis_type
==
"
all
"
and
args
.
save_path
is
None
:
raise
Exception
(
"
When the analysis type is all, a path must be given.
"
)
raise
Exception
(
"
When the analysis type is all, a
--save_
path must be given.
"
)
if
args
.
analysis_type
in
fdict
:
if
args
.
analysis_type
in
fdict
:
if
args
.
labels
is
None
:
if
args
.
labels
is
None
:
...
...
This diff is collapsed.
Click to expand it.
src/robofish/evaluate/evaluate.py
+
27
−
26
View file @
0156cacc
...
@@ -60,7 +60,6 @@ def evaluate_speed(
...
@@ -60,7 +60,6 @@ def evaluate_speed(
# Exclude possible nans
# Exclude possible nans
path_speeds
=
np
.
array
(
path_speeds
)
path_speeds
=
np
.
array
(
path_speeds
)
path_speeds
=
path_speeds
[
~
np
.
isnan
(
path_speeds
)]
left_quantiles
.
append
(
np
.
quantile
(
path_speeds
,
0.001
))
left_quantiles
.
append
(
np
.
quantile
(
path_speeds
,
0.001
))
right_quantiles
.
append
(
np
.
quantile
(
path_speeds
,
0.999
))
right_quantiles
.
append
(
np
.
quantile
(
path_speeds
,
0.999
))
...
@@ -117,9 +116,7 @@ def evaluate_turn(
...
@@ -117,9 +116,7 @@ def evaluate_turn(
for
e_speeds_turns
in
speeds_turns
:
for
e_speeds_turns
in
speeds_turns
:
path_turns
.
extend
(
np
.
rad2deg
(
e_speeds_turns
[:,
1
]))
path_turns
.
extend
(
np
.
rad2deg
(
e_speeds_turns
[:,
1
]))
# Exclude possible nans
path_turns
=
np
.
array
(
path_turns
)
path_turns
=
np
.
array
(
path_turns
)
path_turns
=
path_turns
[
~
np
.
isnan
(
path_turns
)]
left_quantiles
.
append
(
np
.
quantile
(
path_turns
,
0.001
))
left_quantiles
.
append
(
np
.
quantile
(
path_turns
,
0.001
))
right_quantiles
.
append
(
np
.
quantile
(
path_turns
,
0.999
))
right_quantiles
.
append
(
np
.
quantile
(
path_turns
,
0.999
))
...
@@ -393,8 +390,8 @@ def evaluate_tank_position(
...
@@ -393,8 +390,8 @@ def evaluate_tank_position(
new_xy_positions
=
np
.
concatenate
(
new_xy_positions
=
np
.
concatenate
(
[
p
[:,
::
poses_step
,
:
2
].
reshape
(
-
1
,
2
)
for
p
in
poses_per_path
],
axis
=
0
[
p
[:,
::
poses_step
,
:
2
].
reshape
(
-
1
,
2
)
for
p
in
poses_per_path
],
axis
=
0
)
)
# Exclude possible nans
xy_positions
.
append
(
new_xy_positions
[
~
np
.
isnan
(
new_xy_positions
).
any
(
axis
=
1
)]
)
xy_positions
.
append
(
new_xy_positions
)
fig
,
ax
=
plt
.
subplots
(
1
,
len
(
xy_positions
),
figsize
=
(
8
*
len
(
xy_positions
),
8
))
fig
,
ax
=
plt
.
subplots
(
1
,
len
(
xy_positions
),
figsize
=
(
8
*
len
(
xy_positions
),
8
))
if
len
(
xy_positions
)
==
1
:
if
len
(
xy_positions
)
==
1
:
...
@@ -466,11 +463,7 @@ def evaluate_social_vector(
...
@@ -466,11 +463,7 @@ def evaluate_social_vector(
)
)
)
)
# Concatenate and exclude possible nans
socialVec
.
append
(
np
.
concatenate
(
path_socialVec
,
axis
=
0
))
path_socialVec
=
np
.
concatenate
(
path_socialVec
,
axis
=
0
)
path_socialVec
=
path_socialVec
[
~
np
.
isnan
(
path_socialVec
).
any
(
axis
=
1
)]
socialVec
.
append
(
path_socialVec
)
grids
=
[]
grids
=
[]
...
@@ -535,30 +528,37 @@ def evaluate_follow_iid(
...
@@ -535,30 +528,37 @@ def evaluate_follow_iid(
calculate_follow
(
poses
[
i
,
:,
:
2
],
poses
[
j
,
:,
:
2
])
calculate_follow
(
poses
[
i
,
:,
:
2
],
poses
[
j
,
:,
:
2
])
)
)
follow
.
append
(
np
.
array
(
path_follow
))
follow
.
append
(
np
.
concatenate
([
np
.
atleast_1d
(
f
)
for
f
in
path_follow
]
))
iid
.
append
(
np
.
array
(
path_iid
))
iid
.
append
(
np
.
concatenate
([
np
.
atleast_1d
(
i
)
for
i
in
path_iid
]
))
grids
=
[]
grids
=
[]
follow_flat
=
np
.
concatenate
([
f
.
flatten
()
for
f
in
follow
])
iid_flat
=
np
.
concatenate
([
i
.
flatten
()
for
i
in
iid
])
# Exclude possible nans
# Exclude possible nans
follow_flat
=
follow_flat
[
~
np
.
isnan
(
follow_flat
)]
iid_flat
=
iid_flat
[
~
np
.
isnan
(
iid_flat
)]
# Find the 0.5%/ 99.5% quantiles as min and max for the axis
# Find the 0.5%/ 99.5% quantiles as min and max for the axis
follow_range
=
np
.
max
(
follow_range
=
np
.
max
(
[
-
1
*
np
.
quantile
(
follow_flat
,
0.005
),
np
.
quantile
(
follow_flat
,
0.995
)]
[
-
1
*
np
.
quantile
(
np
.
concatenate
(
follow
),
0.1
),
np
.
quantile
(
np
.
concatenate
(
follow
),
0.9
),
]
)
)
max_iid
=
np
.
quantile
(
iid_
flat
,
0.9
95
)
max_iid
=
np
.
quantile
(
np
.
concatenate
(
iid
,
dtype
=
np
.
fl
o
at
32
)
,
0.9
)
for
i
in
range
(
len
(
follow
)):
for
i
in
range
(
len
(
follow
)):
# Mask data which is outside of the ranges
mask
=
(
(
follow
[
i
]
>
-
1
*
follow_range
)
&
(
follow
[
i
]
<
follow_range
)
&
(
iid
[
i
]
<
max_iid
)
)
follow_iid_data
=
pd
.
DataFrame
(
follow_iid_data
=
pd
.
DataFrame
(
{
{
"
IID [cm]
"
:
np
.
concatenate
(
iid
[
i
],
axis
=
0
),
"
IID [cm]
"
:
iid
[
i
][
mask
],
"
Follow
"
:
np
.
concatenate
(
follow
[
i
],
axis
=
0
),
"
Follow
"
:
follow
[
i
][
mask
],
}
},
dtype
=
np
.
float32
,
)
)
plt
.
rcParams
[
"
lines.markersize
"
]
=
1
plt
.
rcParams
[
"
lines.markersize
"
]
=
1
...
@@ -569,9 +569,10 @@ def evaluate_follow_iid(
...
@@ -569,9 +569,10 @@ def evaluate_follow_iid(
kind
=
"
hist
"
,
kind
=
"
hist
"
,
xlim
=
(
0
,
max_iid
),
xlim
=
(
0
,
max_iid
),
ylim
=
(
-
follow_range
,
follow_range
),
ylim
=
(
-
follow_range
,
follow_range
),
cbar
=
True
,
# cbar=True,
legend
=
True
,
# legend=True,
joint_kws
=
{
"
bins
"
:
50
},
joint_kws
=
{
"
bins
"
:
30
},
marginal_kws
=
dict
(
bins
=
30
),
)
)
# grid.fig.set_figwidth(9)
# grid.fig.set_figwidth(9)
# grid.fig.set_figheight(6)
# grid.fig.set_figheight(6)
...
@@ -623,7 +624,7 @@ def evaluate_tracks(
...
@@ -623,7 +624,7 @@ def evaluate_tracks(
file_settings
=
None
,
file_settings
=
None
,
lw_distances
=
False
,
lw_distances
=
False
,
seed
=
42
,
seed
=
42
,
max_timesteps
=
4000
,
max_timesteps
=
None
,
):
):
"""
Evaluate the track.
"""
Evaluate the track.
...
...
This diff is collapsed.
Click to expand it.
src/robofish/io/utils.py
+
4
−
0
View file @
0156cacc
...
@@ -104,6 +104,10 @@ def get_all_data_from_paths(
...
@@ -104,6 +104,10 @@ def get_all_data_from_paths(
data
=
file
.
select_entity_property
(
data
=
file
.
select_entity_property
(
pred
,
entity_property
=
properties
[
request_type
]
pred
,
entity_property
=
properties
[
request_type
]
)
)
# Exclude timesteps where there is any nan in the row
data
=
data
[:,
~
np
.
isnan
(
data
).
any
(
axis
=
2
).
any
(
axis
=
0
)]
data_from_files
.
append
(
data
)
data_from_files
.
append
(
data
)
all_data
.
append
(
data_from_files
)
all_data
.
append
(
data_from_files
)
...
...
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