def analyze_pmp(ts, query, sample_pct, threshold, windows=None, n_jobs=-1): """ Computes the Pan-MatrixProfile, top 3 motifs and top 3 discords for the provided time series and query. Additionally, plots for the PMP, motifs and discords is provided. Parameters ---------- ts : array_like The time series to analyze. query : array_like The query to analyze. sample_pct : float A float between 0 and 1 representing how many samples to compute for the PMP. threshold : float A correlation threshold between 0 and 1 that is used to compute the upper window. Note that this is used only when the windows is None. windows : array_like, default None Integers representing the desired windows to use during the computation of the PMP. n_jobs : int, default -1 (all cpu cores) The number of cpu cores to use when computing the PMP. Returns ------- tuple : (profile, figures) A tuple with the first item being the profile and the second being an array of matplotlib figures. """ ts = core.to_np_array(ts) if isinstance(threshold, type(None)): threshold = 0.98 # when a threshold is passed, we compute the upper window profile = None if isinstance(windows, type(None)): profile = maximum_subsequence(ts, threshold, include_pmp=True) # determine windows to be computed # from 8 in steps of 2 until upper w start = 8 windows = range(start, profile['upper_window'] + 1) # compute the pmp profile = skimp(ts, windows=windows, sample_pct=sample_pct, pmp_obj=profile) # extract top motifs profile = motifs(profile) # extract top discords profile = discords(profile) # plot pmp figures = visualize(profile) return (profile, figures)
def analyze_mp_approximate(ts, query, window, sample_pct, n_jobs=-1): """ Computes the exact MatrixProfile, top 3 motifs and top 3 discords for the provided time series and query. Additionally, the MatrixProfile, discords and motifs are visualized. Parameters ---------- ts : array_like The time series to analyze. query : array_like The query to analyze. window : int The window size to compute the MatrixProfile. sample_pct : float A float between 0 and 1 representing how many samples to compute for the MP. When it is 1, it is the same as using the exact algorithm. n_jobs : int, default -1 (all cpu cores) The number of cpu cores to use when computing the MP. Returns ------- tuple : (profile, figures) A tuple with the first item being the profile and the second being an array of matplotlib figures. """ ts = core.to_np_array(ts) # compute mp profile = scrimp_plus_plus(ts, window, query=query, sample_pct=sample_pct, n_jobs=n_jobs) # extract top motifs profile = motifs(profile) # extract top discords profile = discords(profile) # plot mp figures = visualize(profile) return (profile, figures)
def analyze_mp_exact(ts, query, window, n_jobs=-1): """ Computes the exact MatrixProfile, top 3 motifs and top 3 discords for the provided time series and query. Additionally, the MatrixProfile, discords and motifs are visualized. Parameters ---------- ts : array_like The time series to analyze. query : array_like The query to analyze. window : int The window size to compute the MatrixProfile. n_jobs : int, default -1 (all cpu cores) The number of cpu cores to use when computing the MP. Returns ------- tuple : (profile, figures) A tuple with the first item being the profile and the second being an array of matplotlib figures. """ ts = core.to_np_array(ts) # compute mp profile = mpx(ts, window, query=query, n_jobs=n_jobs) # extract top motifs profile = motifs(profile) # extract top discords profile = discords(profile) # plot mp figures = visualize(profile) return (profile, figures)