Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Calculate the Matrix Profile using the more efficient MASS calculation. Distance profiles are computed in a random order.
Parameters
----------
tsA: Time series containing the queries for which to calculate the Matrix Profile.
m: Length of subsequence to compare.
tsB: Time series to compare the query against. Note that, if no value is provided, tsB = tsA by default.
sampling: The percentage of all possible distance profiles to sample for the final Matrix Profile. 0 to 1
n_threads: Number of threads to use in parallel mode. Defaults to single threaded mode. Set to -1 to use all threads.
random_state: Set the random seed generator for reproducible results.
"""
if sampling > 1 or sampling < 0:
raise ValueError('Sampling value must be a percentage in decimal format from 0 to 1.')
if n_threads is None:
return _matrixProfile_sampling(tsA,m,order.randomOrder,distanceProfile.massDistanceProfile,tsB,sampling=sampling,random_state=random_state)
return _stamp_parallel(tsA, m, tsB=tsB, sampling=sampling, n_threads=n_threads, random_state=random_state)
def naiveMP(tsA,m,tsB=None):
"""
Calculate the Matrix Profile using the naive all-pairs calculation.
Parameters
----------
tsA: Time series containing the queries for which to calculate the Matrix Profile.
m: Length of subsequence to compare.
tsB: Time series to compare the query against. Note that, if no value is provided, tsB = tsA by default.
"""
return _matrixProfile(tsA,m,order.linearOrder,distanceProfile.naiveDistanceProfile,tsB)