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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Commits
a0f688f4
Commit
a0f688f4
authored
3 years ago
by
Raphael Sturgis
Browse files
Options
Downloads
Patches
Plain Diff
minor
parent
d501d077
No related branches found
No related tags found
1 merge request
!6
Develop
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+2
-1
2 additions, 1 deletion
.gitignore
requirements.txt
+2
-1
2 additions, 1 deletion
requirements.txt
skais/ais/ais_trajectory.py
+23
-3
23 additions, 3 deletions
skais/ais/ais_trajectory.py
skais/learn/hmm_gmm_classifier.py
+0
-1
0 additions, 1 deletion
skais/learn/hmm_gmm_classifier.py
with
27 additions
and
6 deletions
.gitignore
+
2
−
1
View file @
a0f688f4
.idea/*
build/
skais.egg-info/
*.coverage
\ No newline at end of file
*.coverage
*__pycache__*
This diff is collapsed.
Click to expand it.
requirements.txt
+
2
−
1
View file @
a0f688f4
...
...
@@ -3,4 +3,5 @@ setuptools~=57.0.0
numpy
~=1.19.5
numba
~=0.53.1
scipy
~=1.5.4
POT
~=0.7.0
\ No newline at end of file
hmmlearn
~=0.2.6
scikit-learn
~=1.0.1
\ No newline at end of file
This diff is collapsed.
Click to expand it.
skais/ais/ais_trajectory.py
+
23
−
3
View file @
a0f688f4
...
...
@@ -5,6 +5,7 @@ import numpy as np
from
numba
import
jit
from
scipy.interpolate
import
interp1d
from
skais.stats.angluar
import
angular_dispersion
from
skais.utils.geography
import
great_circle
from
skais.utils.stats
import
calc_std_dev
...
...
@@ -155,7 +156,7 @@ def l1_angle(dat, radius):
dat
=
np
.
concatenate
([
np
.
full
(
radius
,
dat
[
0
]),
dat
,
np
.
full
(
radius
,
dat
[
-
1
])])
for
i
in
range
(
radius
,
dat
.
shape
[
0
]
-
radius
):
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
l1
[
i
-
radius
]
=
np
.
linalg
.
norm
(
data
,
ord
=
1
)
return
l1
...
...
@@ -166,11 +167,20 @@ def l2_angle(dat, radius):
dat
=
np
.
concatenate
([
np
.
full
(
radius
,
dat
[
0
]),
dat
,
np
.
full
(
radius
,
dat
[
-
1
])])
for
i
in
range
(
radius
,
dat
.
shape
[
0
]
-
radius
):
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
l2
[
i
-
radius
]
=
np
.
linalg
.
norm
(
data
,
ord
=
2
)
return
l2
def
angle_dispersion
(
dat
,
radius
):
l2
=
np
.
zeros
(
dat
.
shape
)
dat
=
np
.
concatenate
([
np
.
full
(
radius
,
dat
[
0
]),
dat
,
np
.
full
(
radius
,
dat
[
-
1
])])
for
i
in
range
(
radius
,
dat
.
shape
[
0
]
-
radius
):
data
=
dat
[
i
-
radius
:
i
+
radius
+
1
]
l2
[
i
-
radius
]
=
angular_dispersion
(
np
.
radians
(
data
))
class
AISTrajectory
:
def
__init__
(
self
,
df
,
interpolation_time
=
None
):
df
=
df
.
drop_duplicates
(
subset
=
[
'
ts_sec
'
])
...
...
@@ -181,7 +191,7 @@ class AISTrajectory:
discrete_columns
=
[
'
navstatus
'
,
'
label
'
]
new_df
=
pd
.
DataFrame
()
t_raw
=
df
[
'
ts_sec
'
].
to_numpy
()
t_interp1d
=
np
.
arange
(
start
=
t_raw
[
0
],
stop
=
t_raw
[
-
1
]
+
1
,
t_interp1d
=
np
.
arange
(
start
=
t_raw
[
0
],
stop
=
t_raw
[
-
1
]
+
1
,
step
=
interpolation_time
*
60
)
new_df
[
'
ts_sec
'
]
=
t_interp1d
...
...
@@ -267,6 +277,16 @@ class AISTrajectory:
stds
[:
radius
]
=
np
.
nan
self
.
df
[
f
"
{
field
}
_std
"
]
=
stds
def
compute_all_dispersions
(
self
,
radius
):
fields
=
[
'
cog
'
,
'
heading
'
,
'
angles_diff
'
]
for
field
in
fields
:
if
field
in
self
.
df
.
columns
:
dat
=
self
.
df
[
field
].
to_numpy
()
disp
=
angle_dispersion
(
dat
,
radius
)
disp
[
-
radius
:]
=
np
.
nan
disp
[:
radius
]
=
np
.
nan
self
.
df
[
f
"
{
field
}
_disp
"
]
=
disp
def
compute_position_features
(
self
,
radius
):
dat
=
np
.
stack
([
self
.
df
.
longitude
.
to_numpy
(),
self
.
df
.
latitude
.
to_numpy
()],
axis
=
1
)
std
=
compute_position_angle_std
(
dat
,
radius
)
...
...
This diff is collapsed.
Click to expand it.
skais/learn/hmm_gmm_classifier.py
+
0
−
1
View file @
a0f688f4
import
random
from
hmmlearn.hmm
import
GMMHMM
,
GaussianHMM
from
matplotlib
import
pyplot
as
plt
from
numba
import
jit
from
scipy
import
linalg
from
sklearn.datasets
import
make_spd_matrix
...
...
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