Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
f028709
Add naive implementation of stump_topk
NimaSarajpoor Apr 28, 2022
e893873
Copy test_stump code to test_stump_topk
NimaSarajpoor Apr 28, 2022
986311f
change replace naive.stump with naive.stump_topk
NimaSarajpoor Apr 28, 2022
9d8aafc
Add self-join tests for 1NN and KNN
NimaSarajpoor Apr 28, 2022
121686b
remove variable k in 1NN test
NimaSarajpoor Apr 28, 2022
730bfbb
Fixed passing input to test function
NimaSarajpoor Apr 28, 2022
f78348f
Fixed minor bug
NimaSarajpoor Apr 28, 2022
c9baf93
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor Apr 28, 2022
e09b5f0
Correct format
NimaSarajpoor Apr 28, 2022
95a8c08
Erase function stump_topk
NimaSarajpoor Apr 29, 2022
d0701fe
Revise naive.stump to return topk NN matrix profile
NimaSarajpoor Apr 29, 2022
5444599
Added a few comments
NimaSarajpoor Apr 29, 2022
9ebb08a
Add one new test case for topk matrix profile
NimaSarajpoor Apr 29, 2022
d83e8e6
Removed unnecessary test file
NimaSarajpoor Apr 29, 2022
9c8f019
Set I to -1 if its corresponding P is not finite
NimaSarajpoor Apr 30, 2022
0ce9595
Removed new test function
NimaSarajpoor Apr 30, 2022
a972698
Fixed format
NimaSarajpoor Apr 30, 2022
e2d3061
minor change
NimaSarajpoor Apr 30, 2022
1938f63
minor change
NimaSarajpoor Apr 30, 2022
0e25a34
Add new test function for topk matrix profile
NimaSarajpoor Apr 30, 2022
e393585
Fixed format
NimaSarajpoor Apr 30, 2022
659d5e7
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor May 2, 2022
850a594
Use diagonal traversal to get top-k matrix profile
NimaSarajpoor May 2, 2022
278e76c
Fixed shape of naive.stump output
NimaSarajpoor May 2, 2022
a864662
Add naive version of numpy.searchsorted
NimaSarajpoor May 2, 2022
f0c022d
Replace numpy.searchsorted with its naive version
NimaSarajpoor May 2, 2022
81701ba
Fixed calling function searchsorted
NimaSarajpoor May 2, 2022
e244341
Fixed format
NimaSarajpoor May 2, 2022
fd4a7a5
Resolved Merge Conflict
NimaSarajpoor May 9, 2022
1806c66
minor changes
NimaSarajpoor May 9, 2022
ad29c19
Correct format
NimaSarajpoor May 9, 2022
448d65d
Correct flake8 style
NimaSarajpoor May 9, 2022
e3ebcb5
Avoid unnecessary slicing
NimaSarajpoor May 9, 2022
3cee5d8
pass parameter k to function stump
NimaSarajpoor May 10, 2022
a1bc6a4
Add parameter k to function stump
NimaSarajpoor May 10, 2022
384690c
Add parameter k to function _stump
NimaSarajpoor May 10, 2022
d246736
Fixed update of top-k rho and indices in _stump
NimaSarajpoor May 10, 2022
fdff040
Add parameter k to function _compute_diagonal
NimaSarajpoor May 10, 2022
9d72198
consider parameter k in non normalized function, decorator
NimaSarajpoor May 10, 2022
995559f
Fixed missing input parameter k in function _compute_diagonal
NimaSarajpoor May 10, 2022
a047dd0
minor change
NimaSarajpoor May 10, 2022
c6370b6
Add verbose
NimaSarajpoor May 10, 2022
8164415
minor changes
NimaSarajpoor May 10, 2022
7007953
Fixed unit test for top-k matrix profile
NimaSarajpoor May 10, 2022
5b5f21a
Remove parameter k in function non_normalized decorator
NimaSarajpoor May 10, 2022
f7ee854
Corret format by black
NimaSarajpoor May 10, 2022
485dba3
Use seperate variaboles for left and right profiles
NimaSarajpoor May 12, 2022
bc133ca
store top-k rho in ascending order
NimaSarajpoor May 13, 2022
47a61b2
Revise docstrings
NimaSarajpoor May 13, 2022
d4dc04a
Correct docstrings
NimaSarajpoor May 13, 2022
a123540
Correct formats
NimaSarajpoor May 13, 2022
1dff66f
Full coverage of test_stump unit test
NimaSarajpoor May 13, 2022
cf48b69
Change function considering new input/output structure
NimaSarajpoor May 13, 2022
7d16ce6
Add two more outputs returned by _stump
NimaSarajpoor May 13, 2022
61d38b6
Update/Correct docstrings
NimaSarajpoor May 13, 2022
1a469a5
Correct callee function _stump
NimaSarajpoor May 13, 2022
2149abf
Fix format
NimaSarajpoor May 13, 2022
364f280
Fixed number of inputs passed to _stump
NimaSarajpoor May 13, 2022
e983e1f
Fixed number of outputs returned by the function
NimaSarajpoor May 13, 2022
ef2bc65
Fixed number of returned outputs
NimaSarajpoor May 13, 2022
f7d4a8f
Correct format
NimaSarajpoor May 13, 2022
3dccc9a
Exclude parameter 'k' in non-normalized decorator
NimaSarajpoor May 13, 2022
a430364
Correct format
NimaSarajpoor May 13, 2022
4f01943
Fixed dtype of matrix profile indices
NimaSarajpoor May 13, 2022
aebe5a3
Add pagam no cover
NimaSarajpoor May 13, 2022
de295af
Minor change
NimaSarajpoor May 13, 2022
1d35aea
Use range to move in reverse
NimaSarajpoor May 16, 2022
3337416
seperate variables for left and right
NimaSarajpoor May 17, 2022
d09ea23
use seperate variables for left and right
NimaSarajpoor May 17, 2022
dbd7b8c
replace numpy column_stack with c_
NimaSarajpoor May 17, 2022
56ab764
Fix bug
NimaSarajpoor May 17, 2022
e817e5f
Remove a wrongly created file
NimaSarajpoor May 18, 2022
c1e3925
Remove parameter k in non normalized decorator
NimaSarajpoor May 18, 2022
aa08176
Add parameter k to arguments of non normalized function
NimaSarajpoor May 18, 2022
37a9f2c
Replace numpy c_ with column_stack
NimaSarajpoor May 18, 2022
8c0e76e
Minor changes
NimaSarajpoor May 18, 2022
df4c5d1
Correct Format
NimaSarajpoor May 18, 2022
c5c881b
minor improvement of docstring
NimaSarajpoor May 18, 2022
d9dcdc0
Add parameter k to the arguments of function
NimaSarajpoor May 18, 2022
c6b81f0
Add parameter k to arguments
NimaSarajpoor May 18, 2022
4ffc7fc
Correct format
NimaSarajpoor May 18, 2022
102c627
Remove parameter k from arguements
NimaSarajpoor May 18, 2022
a37f793
Add one new unit test
NimaSarajpoor May 18, 2022
0755af4
Add parameter k=1 to arguments
NimaSarajpoor May 18, 2022
ca9fdcf
Revise stumped to return top-k matrix profile
NimaSarajpoor May 18, 2022
9408631
Correct format
NimaSarajpoor May 18, 2022
435d9b8
several minor changes
NimaSarajpoor May 18, 2022
c6580c8
Correct Format
NimaSarajpoor May 18, 2022
e4b0473
Remove k from arguments
NimaSarajpoor May 18, 2022
8bf05ee
Pass 1 as value of parameter k to a class method to avoid unit test f…
NimaSarajpoor May 18, 2022
f12261c
Pass 1 as the value of parameter k to avoid unit test failure
NimaSarajpoor May 18, 2022
695343e
Use np searchsort to avoid copying arrays into new memory
NimaSarajpoor May 19, 2022
f4a37fa
All tests passed
NimaSarajpoor May 19, 2022
2020626
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor May 19, 2022
b6d3763
Replace nested for loops with numpy operations
NimaSarajpoor May 20, 2022
cc9c076
Change the order of some variables in inputs and outputs
NimaSarajpoor May 21, 2022
a4d4566
Revise docstrings and comments
NimaSarajpoor May 21, 2022
5ab2978
Fixed order of outputs returned in _stump
NimaSarajpoor May 21, 2022
6460a5b
Add new function to update TopK MatrixProfile
NimaSarajpoor May 21, 2022
d94db72
Add .copy() to update array properly
NimaSarajpoor May 21, 2022
72c3887
Add new test function for TopK MatrixProfile with gpu_stump
NimaSarajpoor May 21, 2022
0068358
Enhance gpu_stump to return TopK MatrixProfile
NimaSarajpoor May 22, 2022
1e7c05e
Refactored function for merging two TopK MatrixProfile
NimaSarajpoor May 22, 2022
2ebc276
Clean up code
NimaSarajpoor May 22, 2022
1170f2e
Add naive version of merge_topk_matrix_profile function
NimaSarajpoor May 22, 2022
2a827b4
Rename function
NimaSarajpoor May 22, 2022
cc62c74
Revise naive function to make it more readable
NimaSarajpoor May 22, 2022
b6b74c4
Add test function for merge_topk_PI
NimaSarajpoor May 22, 2022
b6d6450
Moved naive function to naive.py
NimaSarajpoor May 22, 2022
97a04f4
Correct Format
NimaSarajpoor May 22, 2022
50f4ee8
Correct Style
NimaSarajpoor May 22, 2022
5b7da52
Add parameter k to avoid failure in non-normalized decorater unit test
NimaSarajpoor May 23, 2022
e983ef0
Skip a for-loop in unit test coverage
NimaSarajpoor May 23, 2022
b0c5cac
All tests pass
NimaSarajpoor May 23, 2022
787e3f7
Use randomly generated arrays for test function
NimaSarajpoor May 23, 2022
2ff2b85
Add minor comment
NimaSarajpoor May 23, 2022
c306027
Erase unnecessary comments
NimaSarajpoor May 23, 2022
d79238d
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor May 23, 2022
898e9f3
Remove unnecessary copy operation
NimaSarajpoor May 23, 2022
3541fae
Major revision in function _merge_topk_PI
NimaSarajpoor May 24, 2022
f93a8dc
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor May 25, 2022
66dff60
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor May 28, 2022
ce8cd4c
Add device function to find insertion index into sorted array
NimaSarajpoor May 28, 2022
09bbe7f
Add test function for gpu_searchsorted
NimaSarajpoor May 28, 2022
4948667
Correct format
NimaSarajpoor May 28, 2022
cdd7a33
Fixed minor bug
NimaSarajpoor May 28, 2022
71ade47
Fixed the name of a variable
NimaSarajpoor May 28, 2022
ac472fc
Fixed grammatical error in docstring
NimaSarajpoor May 28, 2022
fc149e6
Use device function for searchsorting
NimaSarajpoor May 28, 2022
7ac67a8
Correct style
NimaSarajpoor May 28, 2022
92467e2
Remove signature from cuda device function
NimaSarajpoor May 28, 2022
bdfb258
Full Coverage confirmed
NimaSarajpoor May 29, 2022
bb5de99
revising the definiton of parameter bfs in docstring
NimaSarajpoor May 29, 2022
a005a41
Copy array into device memory before passing it to kernel function
NimaSarajpoor May 30, 2022
ade9bb4
use float values for generating arrays
NimaSarajpoor May 30, 2022
853c2ec
move device function to gpu_stump module
NimaSarajpoor May 31, 2022
e3b5119
Add gpu_searchsorted_left for the sake completeness
NimaSarajpoor May 31, 2022
c5779e5
Move test function to test_gpu_stump
NimaSarajpoor May 31, 2022
38e531c
correct format
NimaSarajpoor May 31, 2022
5a7b3c0
Fixed calling function
NimaSarajpoor May 31, 2022
e1b0d20
Make function callable from both CPU and GPU
NimaSarajpoor May 31, 2022
922544c
Fixed calling function
NimaSarajpoor May 31, 2022
102979b
Revised the test function for merge_topk_PI
NimaSarajpoor May 31, 2022
a8aecf6
Revise docstrings
NimaSarajpoor May 31, 2022
38318ec
Rename variable
NimaSarajpoor May 31, 2022
9470a40
Merge branch 'main' into TopK_MatrixProfile
NimaSarajpoor May 31, 2022
76f97cb
Corrected format
NimaSarajpoor May 31, 2022
347e84f
Merging to recover changes (due to detached head)
NimaSarajpoor Jun 6, 2022
d45733c
Fixed typo
NimaSarajpoor Jun 6, 2022
b2db505
change decorator so that the function can be used ONLY as device func…
NimaSarajpoor Jun 6, 2022
b023b20
considered more than one value for parameter k in unit testing
NimaSarajpoor Jun 6, 2022
833cd43
Merge branch 'main' into TopK_MatrixProfile_Investigator
NimaSarajpoor Jun 6, 2022
2e34834
add test for A_B_join_KNN
NimaSarajpoor Jun 6, 2022
4da7366
swap TA and TB in test function so that the value of k becomes valid
NimaSarajpoor Jun 6, 2022
dcee0f9
Replicating commits 5565904 and 10878fd
NimaSarajpoor Jun 6, 2022
7d5e7fc
Add wrapper kernel function for testing a device function
NimaSarajpoor Jun 7, 2022
862a3e8
Correct format
NimaSarajpoor Jun 7, 2022
90e66be
import missing module
NimaSarajpoor Jun 7, 2022
461e1eb
testing function for more than one value for parameter k
NimaSarajpoor Jun 7, 2022
1de7532
Renamed function to improve readability
NimaSarajpoor Jun 7, 2022
08c75f7
Fixed typos
NimaSarajpoor Jun 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion stumpy/aamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,8 @@ def _aamp(
return np.power(P[0, :, :], 1.0 / p), I[0, :, :]


def aamp(T_A, m, T_B=None, ignore_trivial=True, p=2.0):
def aamp(T_A, m, T_B=None, ignore_trivial=True, p=2.0, k=1):
# function needs to be changed to return top-k matrix profile
"""
Compute the non-normalized (i.e., without z-normalization) matrix profile

Expand All @@ -267,6 +268,11 @@ def aamp(T_A, m, T_B=None, ignore_trivial=True, p=2.0):
p : float, default 2.0
The p-norm to apply for computing the Minkowski distance.

k : int, default 1
The number of top `k` smallest distances used to construct the matrix profile.
Note that this will increase the total computational time and memory usage
when k > 1.

Returns
-------
out : numpy.ndarray
Expand Down
8 changes: 7 additions & 1 deletion stumpy/aamped.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
logger = logging.getLogger(__name__)


def aamped(dask_client, T_A, m, T_B=None, ignore_trivial=True, p=2.0):
def aamped(dask_client, T_A, m, T_B=None, ignore_trivial=True, p=2.0, k=1):
# function needs to be revised to return top-k matrix profile
"""
Compute the non-normalized (i.e., without z-normalization) matrix profile

Expand Down Expand Up @@ -46,6 +47,11 @@ def aamped(dask_client, T_A, m, T_B=None, ignore_trivial=True, p=2.0):
p : float, default 2.0
The p-norm to apply for computing the Minkowski distance.

k : int, default 1
The number of top `k` smallest distances used to construct the matrix profile.
Note that this will increase the total computational time and memory usage
when k > 1.

Returns
-------
out : numpy.ndarray
Expand Down
47 changes: 46 additions & 1 deletion stumpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import inspect

import numpy as np
from numba import njit
from numba import njit, prange
from scipy.signal import convolve
from scipy.ndimage import maximum_filter1d, minimum_filter1d
from scipy import linalg
Expand Down Expand Up @@ -2559,3 +2559,48 @@ def _select_P_ABBA_value(P_ABBA, k, custom_func=None):
MPdist = partition[k]

return MPdist


@njit(parallel=True)
def _merge_topk_PI(PA, PB, IA, IB):
"""
Merge two top-k matrix profiles PA and PB, and update PA (in place) while
prioritizing values of PA in ties. Also, update IA accordingly.

Parameters
----------
PA : numpy.ndarray
a (top-k) matrix profile, with ndim of 2, where values in each row are
sorted in ascending order. Also, it needs to be the same shape as PB.

PB : numpy.ndarray
a (top-k) matrix profile, with ndim of 2, where values in each row are
sorted in ascending order. Also, it needs to be the same shape as PA.

IA : numpy.ndarray
a (top-k) matrix profile indices, corresponding to PA

IB : numpy.ndarray
a (top-k) matrix profile indices, corresponding to PB

Returns
-------
None
"""
for i in prange(PB.shape[0]):
start = 0
stop = np.searchsorted(PA[i], PB[i, -1], side="right")

for j in range(PB.shape[1]):
if PB[i, j] < PA[i, -1]:
idx = np.searchsorted(PA[i, start:stop], PB[i, j], side="right") + start

for g in range(PB.shape[1] - 1, idx, -1):
PA[i, g] = PA[i, g - 1]
IA[i, g] = IA[i, g - 1]

PA[i, idx] = PB[i, j]
IA[i, idx] = IB[i, j]

start = idx
stop += 1 # because of shifting elements to the right by one
9 changes: 8 additions & 1 deletion stumpy/gpu_aamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,9 @@ def _gpu_aamp(
return profile_fname, indices_fname


def gpu_aamp(T_A, m, T_B=None, ignore_trivial=True, device_id=0, p=2.0):
def gpu_aamp(T_A, m, T_B=None, ignore_trivial=True, device_id=0, p=2.0, k=1):
# function needs to be revised to return (top-k) matrix profile and
# matrix profile indices
"""
Compute the non-normalized (i.e., without z-normalization) matrix profile with one
or more GPU devices
Expand Down Expand Up @@ -375,6 +377,11 @@ def gpu_aamp(T_A, m, T_B=None, ignore_trivial=True, device_id=0, p=2.0):
p : float, default 2.0
The p-norm to apply for computing the Minkowski distance.

k : int, default 1
The number of top `k` smallest distances used to construct the matrix profile.
Note that this will increase the total computational time and memory usage
when k > 1.

Returns
-------
out : numpy.ndarray
Expand Down
Loading