Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
3b89a43e
Commit
3b89a43e
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
added normalisation with dictionnary
parent
29df63e3
No related branches found
No related tags found
1 merge request
!6
Develop
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
skais/ais/ais_trajectory.py
+39
-25
39 additions, 25 deletions
skais/ais/ais_trajectory.py
skais/utils/experiment_tools.py
+1
-0
1 addition, 0 deletions
skais/utils/experiment_tools.py
with
40 additions
and
25 deletions
skais/ais/ais_trajectory.py
+
39
−
25
View file @
3b89a43e
...
@@ -224,8 +224,22 @@ class AISTrajectory:
...
@@ -224,8 +224,22 @@ class AISTrajectory:
l2
=
l2_angle
(
dat
,
radius
)
l2
=
l2_angle
(
dat
,
radius
)
self
.
df
[
f
"
angle_l2
"
]
=
l2
self
.
df
[
f
"
angle_l2
"
]
=
l2
def
normalize
(
self
,
features
,
normalization_type
=
"
min-max
"
):
def
normalize
(
self
,
features
,
normalization_type
=
"
min-max
"
,
dictionary
=
None
):
normalization_dict
=
{}
normalization_dict
=
None
if
dictionary
is
not
None
:
if
dictionary
[
"
type
"
]
==
"
min-max
"
:
for
f
in
features
:
minimum
=
dictionary
[
f
"
{
f
}
_minimum
"
]
maximum
=
dictionary
[
f
"
{
f
}
_maximum
"
]
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
minimum
)
/
(
maximum
-
minimum
)
elif
dictionary
[
"
type
"
]
==
"
standardization
"
:
for
f
in
features
:
mean
=
dictionary
[
f
"
{
f
}
_mean
"
]
std
=
dictionary
[
f
"
{
f
}
_std
"
]
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
mean
)
/
std
else
:
normalization_dict
=
{
"
type
"
:
normalization_type
}
if
normalization_type
==
"
min-max
"
:
if
normalization_type
==
"
min-max
"
:
for
f
in
features
:
for
f
in
features
:
minimum
=
self
.
df
[
f
].
min
()
minimum
=
self
.
df
[
f
].
min
()
...
@@ -235,7 +249,6 @@ class AISTrajectory:
...
@@ -235,7 +249,6 @@ class AISTrajectory:
normalization_dict
[
f
"
{
f
}
_maximum
"
]
=
maximum
normalization_dict
[
f
"
{
f
}
_maximum
"
]
=
maximum
elif
normalization_type
==
"
standardization
"
:
elif
normalization_type
==
"
standardization
"
:
normalisation_factors
=
(
"
standardization
"
,
{})
for
f
in
features
:
for
f
in
features
:
mean
=
self
.
df
[
f
].
mean
()
mean
=
self
.
df
[
f
].
mean
()
std
=
self
.
df
[
f
].
std
()
std
=
self
.
df
[
f
].
std
()
...
@@ -249,7 +262,8 @@ class AISTrajectory:
...
@@ -249,7 +262,8 @@ class AISTrajectory:
else
:
else
:
raise
ValueError
(
f
"
{
normalization_type
}
not a valid normalization method. Must be on of [min-max,
"
raise
ValueError
(
f
"
{
normalization_type
}
not a valid normalization method. Must be on of [min-max,
"
f
"
standardization]
"
)
f
"
standardization]
"
)
return
normalization_type
,
normalization_dict
return
normalization_dict
def
compute_derivative
(
self
,
field
):
def
compute_derivative
(
self
,
field
):
dt
=
self
.
df
[
'
ts_sec
'
].
diff
()
/
60
dt
=
self
.
df
[
'
ts_sec
'
].
diff
()
/
60
...
...
This diff is collapsed.
Click to expand it.
skais/utils/experiment_tools.py
+
1
−
0
View file @
3b89a43e
...
@@ -9,6 +9,7 @@ def make_feature_vectors(trajectories, features=None,
...
@@ -9,6 +9,7 @@ def make_feature_vectors(trajectories, features=None,
zero
=
[
0
for
_
in
range
(
nb_classes
)]
zero
=
[
0
for
_
in
range
(
nb_classes
)]
for
trajectory
in
trajectories
:
for
trajectory
in
trajectories
:
trajectory
.
df
.
dropna
(
inplace
=
True
)
if
len
(
trajectory
.
df
.
index
)
>
length_list
:
if
len
(
trajectory
.
df
.
index
)
>
length_list
:
trajectory
.
df
[
'
ts
'
]
=
trajectory
.
df
.
index
trajectory
.
df
[
'
ts
'
]
=
trajectory
.
df
.
index
trajectory
.
compute_all_derivatives
()
trajectory
.
compute_all_derivatives
()
...
...
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