Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lucas Miranda
deepOF
Commits
181ee2ff
Commit
181ee2ff
authored
May 04, 2020
by
lucas_miranda
Browse files
Implements merged_table_dict function
parent
7a6d1d10
Changes
3
Hide whitespace changes
Inline
Side-by-side
main.ipynb
View file @
181ee2ff
This source diff could not be displayed because it is too large. You can
view the blob
instead.
source/classes.py
View file @
181ee2ff
...
...
@@ -31,7 +31,7 @@ class project:
smooth_alpha
=
0.1
,
arena_dims
=
[
1
],
center_coords
=
True
,
distances
=
'
All
'
,
distances
=
"
All
"
,
ego
=
False
,
angles
=
True
,
connectivity
=
None
,
...
...
@@ -513,7 +513,3 @@ class table_dict(dict):
X
=
tsne
.
fit_transform
(
X
)
return
X
,
tsne
class
merged_table_dict
(
table_dict
):
def
__init__
(
self
,
*
args
):
pass
\ No newline at end of file
source/utils.py
View file @
181ee2ff
...
...
@@ -16,6 +16,7 @@ from numba import jit
from
numpy.core.umath_tests
import
inner1d
from
scipy
import
spatial
from
sklearn
import
mixture
from
source.classes
import
*
from
tqdm
import
tqdm_notebook
as
tqdm
...
...
@@ -101,6 +102,40 @@ def rolling_window(a, window_size, window_step, write=True):
a
,
shape
=
shape
,
strides
=
strides
,
writeable
=
write
)[::
window_step
]
def
merge_tables
(
*
args
):
"""
Takes a number of table_dict objects and merges them
Returns a table_dict object of type 'merged'
"""
merged_dict
=
{
key
:
[]
for
key
in
args
[
0
].
keys
()}
for
tabdict
in
args
:
for
key
,
val
in
tabdict
.
items
():
merged_dict
[
key
].
append
(
val
)
merged_tables
=
table_dict
(
{
key
:
pd
.
concat
(
val
,
axis
=
1
,
ignore_index
=
True
)
for
key
,
val
in
merged_dict
.
items
()
},
typ
=
"merged"
,
)
return
merged_tables
@
jit
def
smooth_mult_trajectory
(
series
,
alpha
=
0.15
):
"""smooths a trajectory using exponentially weighted averages"""
result
=
[
series
[
0
]]
for
n
in
range
(
len
(
series
)):
result
.
append
(
alpha
*
series
[
n
]
+
(
1
-
alpha
)
*
result
[
n
-
1
])
return
np
.
array
(
result
)
##### IMAGE/VIDEO PROCESSING FUNCTIONS #####
...
...
@@ -127,17 +162,6 @@ def index_frames(video_list, sample=False, index=0, pkl=False):
return
True
@
jit
def
smooth_mult_trajectory
(
series
,
alpha
=
0.15
):
"""smoothens a trajectory using exponentially weighted averages"""
result
=
[
series
[
0
]]
for
n
in
range
(
len
(
series
)):
result
.
append
(
alpha
*
series
[
n
]
+
(
1
-
alpha
)
*
result
[
n
-
1
])
return
np
.
array
(
result
)
##### BEHAVIOUR RECOGNITION FUNCTIONS #####
...
...
Write
Preview
Supports
Markdown
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