-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.html
1676 lines (1514 loc) · 135 KB
/
api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API — MatrixProfile</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Examples" href="examples.html" />
<link rel="prev" title="Quickstart Guide" href="Quickstart.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" style="background: white" >
<a href="index.html" class="icon icon-home" alt="Documentation Home"> matrixprofile
<img src="_static/mpf-logo.png" class="logo" alt="Logo"/>
</a>
<div class="version">
1.1.6
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="Quickstart.html">Quickstart Guide</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-analyze">matrixprofile.analyze</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-compute">matrixprofile.compute</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-visualize">matrixprofile.visualize</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-preprocess-preprocess">matrixprofile.preprocess.preprocess</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-preprocess-impute-missing">matrixprofile.preprocess.impute_missing</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-preprocess-add-noise-to-series">matrixprofile.preprocess.add_noise_to_series</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-discover-motifs">matrixprofile.discover.motifs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-discover-discords">matrixprofile.discover.discords</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-discover-snippets">matrixprofile.discover.snippets</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-discover-regimes">matrixprofile.discover.regimes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-discover-statistics">matrixprofile.discover.statistics</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-discover-hierarchical-clusters">matrixprofile.discover.hierarchical_clusters</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-stomp">matrixprofile.algorithms.stomp</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-mpx">matrixprofile.algorithms.mpx</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-skimp">matrixprofile.algorithms.skimp</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-mass2">matrixprofile.algorithms.mass2</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-mpdist">matrixprofile.algorithms.mpdist</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-pairwise-dist">matrixprofile.algorithms.pairwise_dist</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-maximum-subsequence">matrixprofile.algorithms.maximum_subsequence</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-prescrimp">matrixprofile.algorithms.prescrimp</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-algorithms-scrimp-plus-plus">matrixprofile.algorithms.scrimp_plus_plus</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-transform-apply-av">matrixprofile.transform.apply_av</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-transform-make-default-av">matrixprofile.transform.make_default_av</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-transform-make-complexity-av">matrixprofile.transform.make_complexity_av</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-transform-make-meanstd-av">matrixprofile.transform.make_meanstd_av</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-transform-make-clipping-av">matrixprofile.transform.make_clipping_av</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-utils-empty-mp">matrixprofile.utils.empty_mp</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-utils-pick-mp">matrixprofile.utils.pick_mp</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-io-to-disk">matrixprofile.io.to_disk</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-io-from-disk">matrixprofile.io.from_disk</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-io-to-json">matrixprofile.io.to_json</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-io-from-json">matrixprofile.io.from_json</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-io-to-mpf">matrixprofile.io.to_mpf</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-io-from-mpf">matrixprofile.io.from_mpf</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-datasets-fetch-available">matrixprofile.datasets.fetch_available</a></li>
<li class="toctree-l2"><a class="reference internal" href="#matrixprofile-datasets-load">matrixprofile.datasets.load</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="Algorithms.html">Algorithms</a></li>
<li class="toctree-l1"><a class="reference internal" href="help.html">Getting Help</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="code_of_conduct.html">Code of Conduct</a></li>
<li class="toctree-l1"><a class="reference internal" href="citations.html">Citations</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/matrix-profile-foundation/matrixprofile">Code Repository (Github)</a></li>
<li class="toctree-l1"><a class="reference external" href="https://matrixprofile.org">Website</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">matrixprofile</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li>API</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/api.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<style>
/* CSS overrides for sphinx_rtd_theme */
/* 24px margin */
.nbinput.nblast.container,
.nboutput.nblast.container {
margin-bottom: 19px; /* padding has already 5px */
}
/* ... except between code cells! */
.nblast.container + .nbinput.container {
margin-top: -19px;
}
.admonition > p:before {
margin-right: 4px; /* make room for the exclamation icon */
}
/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
text-align: unset;
}
</style>
<div class="section" id="api">
<h1>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
<div class="section" id="matrixprofile-analyze">
<h2>matrixprofile.analyze<a class="headerlink" href="#matrixprofile-analyze" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.analyze">
<code class="sig-prename descclassname">matrixprofile.</code><code class="sig-name descname">analyze</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">query</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">windows</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">sample_pct</span><span class="o">=</span><span class="default_value">1.0</span></em>, <em class="sig-param"><span class="n">threshold</span><span class="o">=</span><span class="default_value">0.98</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">preprocessing_kwargs</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/analyze.html#analyze"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.analyze" title="Permalink to this definition">¶</a></dt>
<dd><p>Runs an appropriate workflow based on the parameters passed in. The goal
of this function is to compute all fundamental algorithms on the provided
time series data. For now the following is computed:</p>
<ol class="arabic simple">
<li><p>Matrix Profile - exact or approximate based on sample_pct given that a
window is provided. By default is the exact algorithm.</p></li>
<li><p>Top Motifs - The top 3 motifs are found.</p></li>
<li><p>Top Discords - The top 3 discords are found.</p></li>
<li><p>Plot MP, Motifs and Discords</p></li>
</ol>
<p>When a window is not provided or more than a single window is provided,
the PMP is computed:</p>
<ol class="arabic simple">
<li><p>Compute UPPER window when no window(s) is provided</p></li>
<li><p>Compute PMP for all windows</p></li>
<li><p>Top Motifs</p></li>
<li><p>Top Discords</p></li>
<li><p>Plot PMP, motifs and discords.</p></li>
</ol>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to analyze.</p></li>
<li><p><strong>query</strong> (<em>array_like</em><em>, </em><em>Optional</em>) – The query to analyze. Note that when computing the PMP the query is
ignored!</p></li>
<li><p><strong>windows</strong> (<em>int</em><em> or </em><em>array_like</em><em>, </em><em>Optional</em>) – The window(s) to compute the MatrixProfile. Note that it may be an int
for a single matrix profile computation or an array of ints for
computing the pan matrix profile.</p></li>
<li><p><strong>sample_pct</strong> (<em>float</em><em>, </em><em>default = 1</em>) – A float between 0 and 1 representing how many samples to compute for
the MP or PMP. When it is 1, the exact algorithm is used.</p></li>
<li><p><strong>threshold</strong> (<em>float</em><em>, </em><em>Default 0.98</em>) – The correlation coefficient used as the threshold. It should be between
0 and 1. This is used to compute the upper window size when no
window(s) is given.</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>Default = 1</em>) – Number of cpu cores to use.</p></li>
<li><p><strong>preprocessing_kwargs</strong> (<em>dict</em><em>, </em><em>default = None</em>) – <p>A dictionary object to sets parameters for preprocess function.
A valid preprocessing_kwargs should have the following structure:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'window'</span><span class="p">:</span> <span class="n">The</span> <span class="n">window</span> <span class="n">size</span> <span class="n">to</span> <span class="n">compute</span> <span class="n">the</span> <span class="n">mean</span><span class="o">/</span><span class="n">median</span><span class="o">/</span><span class="n">minimum</span><span class="o">/</span><span class="n">maximum</span> <span class="n">value</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'method'</span><span class="p">:</span> <span class="n">A</span> <span class="n">string</span> <span class="n">indicating</span> <span class="n">the</span> <span class="n">data</span> <span class="n">imputation</span> <span class="n">method</span><span class="p">,</span> <span class="n">which</span> <span class="n">should</span> <span class="n">be</span>
<span class="gp">>>> </span> <span class="s1">'mean'</span><span class="p">,</span> <span class="s1">'median'</span><span class="p">,</span> <span class="s1">'min'</span> <span class="ow">or</span> <span class="s1">'max'</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'direction'</span><span class="p">:</span> <span class="n">A</span> <span class="n">string</span> <span class="n">indicating</span> <span class="n">the</span> <span class="n">data</span> <span class="n">imputation</span> <span class="n">direction</span><span class="p">,</span> <span class="n">which</span> <span class="n">should</span> <span class="n">be</span>
<span class="gp">>>> </span> <span class="s1">'forward'</span><span class="p">,</span> <span class="s1">'fwd'</span><span class="p">,</span> <span class="s1">'f'</span><span class="p">,</span> <span class="s1">'backward'</span><span class="p">,</span> <span class="s1">'bwd'</span><span class="p">,</span> <span class="s1">'b'</span><span class="o">.</span> <span class="n">If</span> <span class="n">the</span> <span class="n">direction</span> <span class="ow">is</span>
<span class="gp">>>> </span> <span class="n">forward</span><span class="p">,</span> <span class="n">we</span> <span class="n">use</span> <span class="n">previous</span> <span class="n">data</span> <span class="k">for</span> <span class="n">imputation</span><span class="p">;</span> <span class="k">if</span> <span class="n">the</span> <span class="n">direction</span> <span class="ow">is</span>
<span class="gp">>>> </span> <span class="n">backward</span><span class="p">,</span> <span class="n">we</span> <span class="n">use</span> <span class="n">subsequent</span> <span class="n">data</span> <span class="k">for</span> <span class="n">imputation</span><span class="o">.</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'add_noise'</span><span class="p">:</span> <span class="n">A</span> <span class="n">boolean</span> <span class="n">value</span> <span class="n">indicating</span> <span class="n">whether</span> <span class="n">noise</span> <span class="n">needs</span> <span class="n">to</span> <span class="n">be</span> <span class="n">added</span> <span class="n">into</span> <span class="n">the</span>
<span class="gp">>>> </span> <span class="n">time</span> <span class="n">series</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
<p>To disable preprocessing procedure, set the preprocessing_kwargs to
None/False/””/{}.</p>
</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>tuple</strong> – The appropriate PMP or MP profile object and associated figures.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>(profile, figures)</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-compute">
<h2>matrixprofile.compute<a class="headerlink" href="#matrixprofile-compute" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.compute">
<code class="sig-prename descclassname">matrixprofile.</code><code class="sig-name descname">compute</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">windows</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">query</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">sample_pct</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">threshold</span><span class="o">=</span><span class="default_value">0.98</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">preprocessing_kwargs</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/compute.html#compute"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.compute" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the exact or approximate MatrixProfile based on the sample percent
specified. Currently, MPX and SCRIMP++ is used for the exact and
approximate algorithms respectively. When multiple windows are passed, the
Pan-MatrixProfile is computed and returned.</p>
<p>By default, only passing in a time series (ts), the Pan-MatrixProfile is
computed based on the maximum upper window algorithm with a correlation
threshold of 0.98.</p>
<p class="rubric">Notes</p>
<p>When multiple windows are passed and the Pan-MatrixProfile is computed, the
query is ignored!</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to analyze.</p></li>
<li><p><strong>windows</strong> (<em>int</em><em>, </em><em>array_like</em>) – The window(s) to compute the MatrixProfile. Note that it may be an int
for a single matrix profile computation or an array of ints for
computing the pan matrix profile.</p></li>
<li><p><strong>query</strong> (<em>array_like</em><em>, </em><em>optional</em>) – The query to analyze. Note that when computing the PMP the query is
ignored!</p></li>
<li><p><strong>sample_pct</strong> (<em>float</em><em>, </em><em>default 1</em>) – A float between 0 and 1 representing how many samples to compute for
the MP or PMP. When it is 1, the exact algorithm is used.</p></li>
<li><p><strong>threshold</strong> (<em>float</em><em>, </em><em>default 0.98</em>) – The correlation coefficient used as the threshold. It should be between
0 and 1. This is used to compute the upper window size when no
window(s) is given.</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>default = 1</em>) – Number of cpu cores to use.</p></li>
<li><p><strong>preprocessing_kwargs</strong> (<em>dict</em><em>, </em><em>default = None</em>) – <p>A dictionary object to sets parameters for preprocess function.
A valid preprocessing_kwargs should have the following structure:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'window'</span><span class="p">:</span> <span class="n">The</span> <span class="n">window</span> <span class="n">size</span> <span class="n">to</span> <span class="n">compute</span> <span class="n">the</span> <span class="n">mean</span><span class="o">/</span><span class="n">median</span><span class="o">/</span><span class="n">minimum</span><span class="o">/</span><span class="n">maximum</span> <span class="n">value</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'method'</span><span class="p">:</span> <span class="n">A</span> <span class="n">string</span> <span class="n">indicating</span> <span class="n">the</span> <span class="n">data</span> <span class="n">imputation</span> <span class="n">method</span><span class="p">,</span> <span class="n">which</span> <span class="n">should</span> <span class="n">be</span>
<span class="gp">>>> </span> <span class="s1">'mean'</span><span class="p">,</span> <span class="s1">'median'</span><span class="p">,</span> <span class="s1">'min'</span> <span class="ow">or</span> <span class="s1">'max'</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'direction'</span><span class="p">:</span> <span class="n">A</span> <span class="n">string</span> <span class="n">indicating</span> <span class="n">the</span> <span class="n">data</span> <span class="n">imputation</span> <span class="n">direction</span><span class="p">,</span> <span class="n">which</span> <span class="n">should</span> <span class="n">be</span>
<span class="gp">>>> </span> <span class="s1">'forward'</span><span class="p">,</span> <span class="s1">'fwd'</span><span class="p">,</span> <span class="s1">'f'</span><span class="p">,</span> <span class="s1">'backward'</span><span class="p">,</span> <span class="s1">'bwd'</span><span class="p">,</span> <span class="s1">'b'</span><span class="o">.</span> <span class="n">If</span> <span class="n">the</span> <span class="n">direction</span> <span class="ow">is</span>
<span class="gp">>>> </span> <span class="n">forward</span><span class="p">,</span> <span class="n">we</span> <span class="n">use</span> <span class="n">previous</span> <span class="n">data</span> <span class="k">for</span> <span class="n">imputation</span><span class="p">;</span> <span class="k">if</span> <span class="n">the</span> <span class="n">direction</span> <span class="ow">is</span>
<span class="gp">>>> </span> <span class="n">backward</span><span class="p">,</span> <span class="n">we</span> <span class="n">use</span> <span class="n">subsequent</span> <span class="n">data</span> <span class="k">for</span> <span class="n">imputation</span><span class="o">.</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'add_noise'</span><span class="p">:</span> <span class="n">A</span> <span class="n">boolean</span> <span class="n">value</span> <span class="n">indicating</span> <span class="n">whether</span> <span class="n">noise</span> <span class="n">needs</span> <span class="n">to</span> <span class="n">be</span> <span class="n">added</span> <span class="n">into</span> <span class="n">the</span>
<span class="gp">>>> </span> <span class="n">time</span> <span class="n">series</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
<p>To disable preprocessing procedure, set the preprocessing_kwargs to
None/False/””/{}.</p>
</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>dict</strong> – The profile computed.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-visualize">
<h2>matrixprofile.visualize<a class="headerlink" href="#matrixprofile-visualize" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.visualize">
<code class="sig-prename descclassname">matrixprofile.</code><code class="sig-name descname">visualize</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">profile</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/visualize.html#visualize"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.visualize" title="Permalink to this definition">¶</a></dt>
<dd><p>Automatically creates plots for the provided data structure. In some cases
many plots are created. For example, when a MatrixProfile is passed with
corresponding motifs and discords, the matrix profile, discords and motifs
will be plotted.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>profile</strong> (<em>dict_like</em>) – A MatrixProfile, Pan-MatrixProfile or Statistics data structure.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>list</strong> – A list of matplotlib figures.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>figures</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-preprocess-preprocess">
<h2>matrixprofile.preprocess.preprocess<a class="headerlink" href="#matrixprofile-preprocess-preprocess" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.preprocess.preprocess">
<code class="sig-prename descclassname">matrixprofile.preprocess.</code><code class="sig-name descname">preprocess</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">window</span></em>, <em class="sig-param"><span class="n">impute_method</span><span class="o">=</span><span class="default_value">'mean'</span></em>, <em class="sig-param"><span class="n">impute_direction</span><span class="o">=</span><span class="default_value">'forward'</span></em>, <em class="sig-param"><span class="n">add_noise</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/preprocess.html#preprocess"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.preprocess.preprocess" title="Permalink to this definition">¶</a></dt>
<dd><p>Preprocesses the given time series by adding noise and imputing missing data.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to be preprocessed.</p></li>
<li><p><strong>window</strong> (<em>int</em>) – The window size to compute the mean/median/minimum value/maximum
value.</p></li>
<li><p><strong>method</strong> (<em>string</em><em>, </em><em>Default = 'mean'</em>) – A string indicating the data imputation method, which should be
‘mean’, ‘median’, ‘min’ or ‘max’.</p></li>
<li><p><strong>direction</strong> (<em>string</em><em>, </em><em>Default = 'forward'</em>) – A string indicating the data imputation direction, which should be
‘forward’, ‘fwd’, ‘f’, ‘backward’, ‘bwd’, ‘b’. If the direction is
forward, we use previous data for imputation; if the direction is
backward, we use subsequent data for imputation.</p></li>
<li><p><strong>add_noise</strong> (<em>bool</em><em>, </em><em>Default = True</em>) – A boolean value indicating whether noise needs to be added into the time series.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>temp</strong> – The time series after being preprocessed.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>array_like</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-preprocess-impute-missing">
<h2>matrixprofile.preprocess.impute_missing<a class="headerlink" href="#matrixprofile-preprocess-impute-missing" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.preprocess.impute_missing">
<code class="sig-prename descclassname">matrixprofile.preprocess.</code><code class="sig-name descname">impute_missing</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">window</span></em>, <em class="sig-param"><span class="n">method</span><span class="o">=</span><span class="default_value">'mean'</span></em>, <em class="sig-param"><span class="n">direction</span><span class="o">=</span><span class="default_value">'forward'</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/preprocess.html#impute_missing"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.preprocess.impute_missing" title="Permalink to this definition">¶</a></dt>
<dd><p>Imputes missing data in time series.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to be handled.</p></li>
<li><p><strong>window</strong> (<em>int</em>) – The window size to compute the mean/median/minimum value/maximum
value.</p></li>
<li><p><strong>method</strong> (<em>string</em><em>, </em><em>Default = 'mean'</em>) – A string indicating the data imputation method, which should be
‘mean’, ‘median’, ‘min’ or ‘max’.</p></li>
<li><p><strong>direction</strong> (<em>string</em><em>, </em><em>Default = 'forward'</em>) – A string indicating the data imputation direction, which should be
‘forward’, ‘fwd’, ‘f’, ‘backward’, ‘bwd’, ‘b’. If the direction is
forward, we use previous data for imputation; if the direction is
backward, we use subsequent data for imputation.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>temp</strong> – The time series after being imputed missing data.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>array_like</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-preprocess-add-noise-to-series">
<h2>matrixprofile.preprocess.add_noise_to_series<a class="headerlink" href="#matrixprofile-preprocess-add-noise-to-series" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.preprocess.add_noise_to_series">
<code class="sig-prename descclassname">matrixprofile.preprocess.</code><code class="sig-name descname">add_noise_to_series</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">series</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/preprocess.html#add_noise_to_series"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.preprocess.add_noise_to_series" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds noise to the given time series.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>series</strong> (<em>array_like</em>) – The time series subsequence to be added noise.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>temp</strong> – The time series subsequence after being added noise.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>array_like</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-discover-motifs">
<h2>matrixprofile.discover.motifs<a class="headerlink" href="#matrixprofile-discover-motifs" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.discover.motifs">
<code class="sig-prename descclassname">matrixprofile.discover.</code><code class="sig-name descname">motifs</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">profile</span></em>, <em class="sig-param"><span class="n">exclusion_zone</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">k</span><span class="o">=</span><span class="default_value">3</span></em>, <em class="sig-param"><span class="n">max_neighbors</span><span class="o">=</span><span class="default_value">10</span></em>, <em class="sig-param"><span class="n">radius</span><span class="o">=</span><span class="default_value">3</span></em>, <em class="sig-param"><span class="n">use_cmp</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="headerlink" href="#matrixprofile.discover.motifs" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the top K number of motifs (patterns) given a matrix profile or a pan
matrix profile. By default the algorithm will find up to 3 motifs (k) and
up to 10 of their neighbors with a radius of 3 * min_dist using the
regular matrix profile. If the profile is a Matrix Profile data structure,
you can also use a Corrected Matrix Profile to compute the motifs.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>profile</strong> (<em>dict</em>) – The output from one of the matrix profile algorithms.</p></li>
<li><p><strong>exclusion_zone</strong> (<em>int</em><em>, </em><em>Default to algorithm ez</em>) – Desired number of values to exclude on both sides of the motif. This
avoids trivial matches. It defaults to half of the computed window
size. Setting the exclusion zone to 0 makes it not apply.</p></li>
<li><p><strong>k</strong> (<em>int</em><em>, </em><em>Default = 3</em>) – Desired number of motifs to find.</p></li>
<li><p><strong>max_neighbors</strong> (<em>int</em><em>, </em><em>Default = 10</em>) – The maximum number of neighbors to include for a given motif.</p></li>
<li><p><strong>radius</strong> (<em>int</em><em>, </em><em>Default = 3</em>) – The radius is used to associate a neighbor by checking if the
neighbor’s distance is less than or equal to dist * radius</p></li>
<li><p><strong>use_cmp</strong> (<em>bool</em><em>, </em><em>Default = False</em>) – Use the Corrected Matrix Profile to compute the motifs (only for
a Matrix Profile data structure).</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>dict</strong> – The original input profile with the addition of the “motifs” key. The
motifs key consists of the following structure.</p>
<p>A list of dicts containing motif indices and their corresponding
neighbor indices.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">[</span>
<span class="gp">>>> </span> <span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'motifs'</span><span class="p">:</span> <span class="p">[</span><span class="n">first_index</span><span class="p">,</span> <span class="n">second_index</span><span class="p">],</span>
<span class="gp">>>> </span> <span class="s1">'neighbors'</span><span class="p">:</span> <span class="p">[</span><span class="n">index</span><span class="p">,</span> <span class="n">index</span><span class="p">,</span> <span class="n">index</span> <span class="o">...</span><span class="n">max_neighbors</span><span class="p">]</span>
<span class="gp">>>> </span> <span class="p">}</span>
<span class="gp">>>> </span><span class="p">]</span>
</pre></div>
</div>
<p>The index is a single value when a MatrixProfile is passed in otherwise
the index contains a row and column index for Pan-MatrixProfile.</p>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-discover-discords">
<h2>matrixprofile.discover.discords<a class="headerlink" href="#matrixprofile-discover-discords" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.discover.discords">
<code class="sig-prename descclassname">matrixprofile.discover.</code><code class="sig-name descname">discords</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">profile</span></em>, <em class="sig-param"><span class="n">exclusion_zone</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">k</span><span class="o">=</span><span class="default_value">3</span></em><span class="sig-paren">)</span><a class="headerlink" href="#matrixprofile.discover.discords" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the top K number of discords (anomalies) given a mp or pmp,
exclusion zone and the desired number of discords. The exclusion zone
nullifies entries on the left and right side of the first and subsequent
discords to remove non-trivial matches. More specifically, a discord found
at location X will more than likely have additional discords to the left or
right of it.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>profile</strong> (<em>dict</em>) – A MatrixProfile or Pan-MatrixProfile structure.</p></li>
<li><p><strong>exclusion_zone</strong> (<em>int</em><em>, </em><em>Default mp algorithm ez</em>) – Desired number of values to exclude on both sides of the anomaly.</p></li>
<li><p><strong>k</strong> (<em>int</em>) – Desired number of discords to find.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><strong>dict</strong> – The original profile object with an additional ‘discords’ key. Take
note that a MatrixProfile discord contains a single value while the
Pan-MatrixProfile contains a row and column index.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-discover-snippets">
<h2>matrixprofile.discover.snippets<a class="headerlink" href="#matrixprofile-discover-snippets" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.discover.snippets">
<code class="sig-prename descclassname">matrixprofile.discover.</code><code class="sig-name descname">snippets</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">snippet_size</span></em>, <em class="sig-param"><span class="n">num_snippets</span><span class="o">=</span><span class="default_value">2</span></em>, <em class="sig-param"><span class="n">window_size</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/snippets.html#snippets"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.discover.snippets" title="Permalink to this definition">¶</a></dt>
<dd><p>The snippets algorithm is used to summarize your time series by
identifying N number of representative subsequences. If you want to
identify typical patterns in your time series, then this is the algorithm
to use.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series.</p></li>
<li><p><strong>snippet_size</strong> (<em>int</em>) – The size of snippet desired.</p></li>
<li><p><strong>num_snippets</strong> (<em>int</em><em>, </em><em>Default 2</em>) – The number of snippets you would like to find.</p></li>
<li><p><strong>window_size</strong> (<em>int</em><em>, </em><em>Default</em><em> (</em><em>snippet_size / 2</em><em>)</em>) – The window size.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>list</strong> – A list of snippets as dictionary objects with the following structure.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="n">index</span><span class="p">:</span> <span class="n">the</span> <span class="n">index</span> <span class="n">of</span> <span class="n">the</span> <span class="n">snippet</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">snippet</span><span class="p">:</span> <span class="n">the</span> <span class="n">snippet</span> <span class="n">values</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">neighbors</span><span class="p">:</span> <span class="n">the</span> <span class="n">starting</span> <span class="n">indices</span> <span class="n">of</span> <span class="nb">all</span> <span class="n">subsequences</span> <span class="n">similar</span> <span class="n">to</span> <span class="n">the</span> <span class="n">current</span> <span class="n">snippet</span>
<span class="gp">>>> </span> <span class="n">fraction</span><span class="p">:</span> <span class="n">fraction</span> <span class="n">of</span> <span class="n">the</span> <span class="n">snippet</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>snippets</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-discover-regimes">
<h2>matrixprofile.discover.regimes<a class="headerlink" href="#matrixprofile-discover-regimes" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.discover.regimes">
<code class="sig-prename descclassname">matrixprofile.discover.</code><code class="sig-name descname">regimes</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">profile</span></em>, <em class="sig-param"><span class="n">num_regimes</span><span class="o">=</span><span class="default_value">3</span></em><span class="sig-paren">)</span><a class="headerlink" href="#matrixprofile.discover.regimes" title="Permalink to this definition">¶</a></dt>
<dd><p>Given a MatrixProfile, compute the corrected arc curve and extract
the desired number of regimes. Regimes are computed with an exclusion
zone of 5 * window size per the authors.</p>
<dl class="simple">
<dt>The author states:</dt><dd><p>This exclusion zone is based on an assumption that regimes will have
multiple repetitions; FLUSS is not able to segment single gesture
patterns.</p>
</dd>
</dl>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>profile</strong> (<em>dict</em>) – Data structure from a MatrixProfile algorithm.</p></li>
<li><p><strong>num_regimes</strong> (<em>int</em>) – The desired number of regimes to find.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>dict</strong> – The original MatrixProfile object with additional keys containing.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'cac'</span><span class="p">:</span> <span class="n">The</span> <span class="n">corrected</span> <span class="n">arc</span> <span class="n">curve</span>
<span class="gp">>>> </span> <span class="s1">'cac_ez'</span><span class="p">:</span> <span class="n">The</span> <span class="n">exclusion</span> <span class="n">zone</span> <span class="n">used</span>
<span class="gp">>>> </span> <span class="s1">'regimes'</span><span class="p">:</span> <span class="n">Array</span> <span class="n">of</span> <span class="n">starting</span> <span class="n">indices</span> <span class="n">indicating</span> <span class="n">a</span> <span class="n">regime</span><span class="o">.</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-discover-statistics">
<h2>matrixprofile.discover.statistics<a class="headerlink" href="#matrixprofile-discover-statistics" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.discover.statistics">
<code class="sig-prename descclassname">matrixprofile.discover.</code><code class="sig-name descname">statistics</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">window_size</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/statistics.html#statistics"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.discover.statistics" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute global and moving statistics for the provided 1D time
series. The statistics computed include the min, max, mean, std. and median
over the window specified and globally.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series.</p></li>
<li><p><strong>window_size</strong> (<em>int</em>) – The size of the window to compute moving statistics over.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>dict</strong> – The global and rolling window statistics.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="n">ts</span><span class="p">:</span> <span class="n">the</span> <span class="n">original</span> <span class="n">time</span> <span class="n">series</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="nb">min</span><span class="p">:</span> <span class="n">the</span> <span class="k">global</span> <span class="n">minimum</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="nb">max</span><span class="p">:</span> <span class="n">the</span> <span class="k">global</span> <span class="n">maximum</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">mean</span><span class="p">:</span> <span class="n">the</span> <span class="k">global</span> <span class="n">mean</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">std</span><span class="p">:</span> <span class="n">the</span> <span class="k">global</span> <span class="n">standard</span> <span class="n">deviation</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">median</span><span class="p">:</span> <span class="n">the</span> <span class="k">global</span> <span class="n">median</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">moving_min</span><span class="p">:</span> <span class="n">the</span> <span class="n">moving</span> <span class="n">minimum</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">moving_max</span><span class="p">:</span> <span class="n">the</span> <span class="n">moving</span> <span class="n">maximum</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">moving_mean</span><span class="p">:</span> <span class="n">the</span> <span class="n">moving</span> <span class="n">mean</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">moving_std</span><span class="p">:</span> <span class="n">the</span> <span class="n">moving</span> <span class="n">standard</span> <span class="n">deviation</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">moving_median</span><span class="p">:</span> <span class="n">the</span> <span class="n">moving</span> <span class="n">median</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">window_size</span><span class="p">:</span> <span class="n">the</span> <span class="n">window</span> <span class="n">size</span> <span class="n">provided</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">class</span><span class="p">:</span> <span class="n">Statistics</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>statistics</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> – If window_size is not an int.
If window_size > len(ts)
If ts is not a list or np.array.
If ts is not 1D.</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-discover-hierarchical-clusters">
<h2>matrixprofile.discover.hierarchical_clusters<a class="headerlink" href="#matrixprofile-discover-hierarchical-clusters" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.discover.hierarchical_clusters">
<code class="sig-prename descclassname">matrixprofile.discover.</code><code class="sig-name descname">hierarchical_clusters</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">X</span></em>, <em class="sig-param"><span class="n">window_size</span></em>, <em class="sig-param"><span class="n">t</span></em>, <em class="sig-param"><span class="n">threshold</span><span class="o">=</span><span class="default_value">0.05</span></em>, <em class="sig-param"><span class="n">method</span><span class="o">=</span><span class="default_value">'single'</span></em>, <em class="sig-param"><span class="n">depth</span><span class="o">=</span><span class="default_value">2</span></em>, <em class="sig-param"><span class="n">criterion</span><span class="o">=</span><span class="default_value">'distance'</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/hierarchical_clustering.html#hierarchical_clusters"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.discover.hierarchical_clusters" title="Permalink to this definition">¶</a></dt>
<dd><p>Cluster M time series into hierarchical clusters using agglomerative
approach. This function is more or less a convenience wrapper around
SciPy’s scipy.cluster.hierarchy functions, but uses the MPDist algorithm
to compute distances between each pair of time series.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Memory usage could potentially high depending on the length of your
time series and how many distances are computed!</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>X</strong> (<em>array_like</em>) – An M x N matrix where M is the time series and N is the observations at
a given time.</p></li>
<li><p><strong>window_size</strong> (<em>int</em>) – The window size used to compute the MPDist.</p></li>
<li><p><strong>t</strong> (<em>scalar</em>) – For criteria ‘inconsistent’, ‘distance’ or ‘monocrit’, this is the
threshold to apply when forming flat clusters.
For ‘maxclust’ criteria, this would be max number of clusters
requested.</p></li>
<li><p><strong>threshold</strong> (<em>float</em><em>, </em><em>Default 0.05</em>) – The percentile in which the MPDist is taken from. By default it is
set to 0.05 based on empircal research results from the paper.
Generally, you should not change this unless you know what you are
doing! This value must be a float greater than 0 and less than 1.</p></li>
<li><p><strong>method</strong> (<em>str</em><em>, </em><em>Default single</em>) – The linkage algorithm to use.
Options: {single, complete, average, weighted}</p></li>
<li><p><strong>depth</strong> (<em>int</em><em>, </em><em>Default 2</em>) – A non-negative value more than 0 to specify the number of levels below
a non-singleton cluster to allow.</p></li>
<li><p><strong>criterion</strong> (<em>str</em><em>, </em><em>Default distance</em>) – <p>Options: {inconsistent, distance, maxclust, monocrit}
The criterion to use in forming flat clusters.</p>
<blockquote>
<div><dl>
<dt><code class="docutils literal notranslate"><span class="pre">inconsistent</span></code> :</dt><dd><p>If a cluster node and all its
descendants have an inconsistent value less than or equal
to <cite>t</cite>, then all its leaf descendants belong to the
same flat cluster. When no non-singleton cluster meets
this criterion, every node is assigned to its own
cluster. (Default)</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">distance</span></code> :</dt><dd><p>Forms flat clusters so that the original
observations in each flat cluster have no greater a
cophenetic distance than <cite>t</cite>.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">maxclust</span></code> :</dt><dd><p>Finds a minimum threshold <code class="docutils literal notranslate"><span class="pre">r</span></code> so that
the cophenetic distance between any two original
observations in the same flat cluster is no more than
<code class="docutils literal notranslate"><span class="pre">r</span></code> and no more than <cite>t</cite> flat clusters are formed.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">monocrit</span></code> :</dt><dd><p>Forms a flat cluster from a cluster node c
with index i when <code class="docutils literal notranslate"><span class="pre">monocrit[j]</span> <span class="pre"><=</span> <span class="pre">t</span></code>.
For example, to threshold on the maximum mean distance
as computed in the inconsistency matrix R with a
threshold of 0.8 do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">MR</span> <span class="o">=</span> <span class="n">maxRstat</span><span class="p">(</span><span class="n">Z</span><span class="p">,</span> <span class="n">R</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
<span class="n">cluster</span><span class="p">(</span><span class="n">Z</span><span class="p">,</span> <span class="n">t</span><span class="o">=</span><span class="mf">0.8</span><span class="p">,</span> <span class="n">criterion</span><span class="o">=</span><span class="s1">'monocrit'</span><span class="p">,</span> <span class="n">monocrit</span><span class="o">=</span><span class="n">MR</span><span class="p">)</span>
</pre></div>
</div>
</dd>
</dl>
</div></blockquote>
</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>Default 1</em>) – The number of cpu cores used to compute the MPDist.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>clusters</strong> – Clustering statistics, distances and labels.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="n">pairwise_distances</span><span class="p">:</span> <span class="n">MPDist</span> <span class="n">between</span> <span class="n">pairs</span> <span class="n">of</span> <span class="n">time</span> <span class="n">series</span> <span class="k">as</span>
<span class="gp">>>> </span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">linkage_matrix</span><span class="p">:</span> <span class="n">clustering</span> <span class="n">linkage</span> <span class="n">matrix</span> <span class="k">as</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">inconsistency_statistics</span><span class="p">:</span> <span class="n">inconsistency</span> <span class="n">stats</span> <span class="k">as</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">assignments</span><span class="p">:</span> <span class="n">cluster</span> <span class="n">label</span> <span class="n">associated</span> <span class="k">with</span> <span class="nb">input</span> <span class="n">X</span> <span class="n">location</span> <span class="k">as</span>
<span class="gp">>>> </span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">cophenet</span><span class="p">:</span> <span class="nb">float</span> <span class="n">the</span> <span class="n">cophenet</span> <span class="n">statistic</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="n">cophenet_distances</span><span class="p">:</span> <span class="n">cophenet</span> <span class="n">distances</span> <span class="n">between</span> <span class="n">pairs</span> <span class="n">of</span> <span class="n">time</span>
<span class="gp">>>> </span> <span class="n">series</span> <span class="k">as</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span>
<span class="gp">>>> </span> <span class="n">class</span><span class="p">:</span> <span class="n">hclusters</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>dict</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-algorithms-stomp">
<h2>matrixprofile.algorithms.stomp<a class="headerlink" href="#matrixprofile-algorithms-stomp" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.algorithms.stomp">
<code class="sig-prename descclassname">matrixprofile.algorithms.</code><code class="sig-name descname">stomp</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">window_size</span></em>, <em class="sig-param"><span class="n">query</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/stomp.html#stomp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.algorithms.stomp" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes matrix profiles for a single dimensional time series using the
parallelized STOMP algorithm (by default). Ray or Python’s multiprocessing
library may be used. When you have initialized Ray on your machine,
it takes priority over using Python’s multiprocessing.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to compute the matrix profile for.</p></li>
<li><p><strong>window_size</strong> (<em>int</em>) – The size of the window to compute the matrix profile over.</p></li>
<li><p><strong>query</strong> (<em>array_like</em>) – Optionally, a query can be provided to perform a similarity join.</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>Default = 1</em>) – Number of cpu cores to use.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>dict</strong> – A MatrixProfile data structure.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'mp'</span><span class="p">:</span> <span class="n">The</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'pi'</span><span class="p">:</span> <span class="n">The</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="mi">1</span><span class="n">NN</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'rmp'</span><span class="p">:</span> <span class="n">The</span> <span class="n">right</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'rpi'</span><span class="p">:</span> <span class="n">The</span> <span class="n">right</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="mi">1</span><span class="n">NN</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'lmp'</span><span class="p">:</span> <span class="n">The</span> <span class="n">left</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'lpi'</span><span class="p">:</span> <span class="n">The</span> <span class="n">left</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="mi">1</span><span class="n">NN</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'metric'</span><span class="p">:</span> <span class="n">The</span> <span class="n">distance</span> <span class="n">metric</span> <span class="n">computed</span> <span class="k">for</span> <span class="n">the</span> <span class="n">mp</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'w'</span><span class="p">:</span> <span class="n">The</span> <span class="n">window</span> <span class="n">size</span> <span class="n">used</span> <span class="n">to</span> <span class="n">compute</span> <span class="n">the</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'ez'</span><span class="p">:</span> <span class="n">The</span> <span class="n">exclusion</span> <span class="n">zone</span> <span class="n">used</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'join'</span><span class="p">:</span> <span class="n">Flag</span> <span class="n">indicating</span> <span class="k">if</span> <span class="n">a</span> <span class="n">similarity</span> <span class="n">join</span> <span class="n">was</span> <span class="n">computed</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'sample_pct'</span><span class="p">:</span> <span class="n">Percentage</span> <span class="n">of</span> <span class="n">samples</span> <span class="n">used</span> <span class="ow">in</span> <span class="n">computing</span> <span class="n">the</span> <span class="n">MP</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'data'</span><span class="p">:</span> <span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'ts'</span><span class="p">:</span> <span class="n">Time</span> <span class="n">series</span> <span class="n">data</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'query'</span><span class="p">:</span> <span class="n">Query</span> <span class="n">data</span> <span class="k">if</span> <span class="n">supplied</span>
<span class="gp">>>> </span> <span class="p">}</span>
<span class="gp">>>> </span> <span class="s1">'class'</span><span class="p">:</span> <span class="s2">"MatrixProfile"</span>
<span class="gp">>>> </span> <span class="s1">'algorithm'</span><span class="p">:</span> <span class="s2">"stomp_parallel"</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> – If window_size < 4.
If window_size > query length / 2.
If ts is not a list or np.array.
If query is not a list or np.array.
If ts or query is not one dimensional.</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-algorithms-mpx">
<h2>matrixprofile.algorithms.mpx<a class="headerlink" href="#matrixprofile-algorithms-mpx" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.algorithms.mpx">
<code class="sig-prename descclassname">matrixprofile.algorithms.</code><code class="sig-name descname">mpx</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">w</span></em>, <em class="sig-param"><span class="n">query</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">cross_correlation</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/mpx.html#mpx"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.algorithms.mpx" title="Permalink to this definition">¶</a></dt>
<dd><p>The MPX algorithm computes the matrix profile without using the FFT.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to compute the matrix profile for.</p></li>
<li><p><strong>w</strong> (<em>int</em>) – The window size.</p></li>
<li><p><strong>query</strong> (<em>array_like</em>) – Optionally a query series.</p></li>
<li><p><strong>cross_correlation</strong> (<em>bool</em><em>, </em><em>Default=False</em>) – Determine if cross_correlation distance should be returned. It defaults
to Euclidean Distance.</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>Default = 1</em>) – Number of cpu cores to use.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>dict</strong> – A MatrixProfile data structure.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'mp'</span><span class="p">:</span> <span class="n">The</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'pi'</span><span class="p">:</span> <span class="n">The</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="mi">1</span><span class="n">NN</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'rmp'</span><span class="p">:</span> <span class="n">The</span> <span class="n">right</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'rpi'</span><span class="p">:</span> <span class="n">The</span> <span class="n">right</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="mi">1</span><span class="n">NN</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'lmp'</span><span class="p">:</span> <span class="n">The</span> <span class="n">left</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'lpi'</span><span class="p">:</span> <span class="n">The</span> <span class="n">left</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="mi">1</span><span class="n">NN</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'metric'</span><span class="p">:</span> <span class="n">The</span> <span class="n">distance</span> <span class="n">metric</span> <span class="n">computed</span> <span class="k">for</span> <span class="n">the</span> <span class="n">mp</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'w'</span><span class="p">:</span> <span class="n">The</span> <span class="n">window</span> <span class="n">size</span> <span class="n">used</span> <span class="n">to</span> <span class="n">compute</span> <span class="n">the</span> <span class="n">matrix</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'ez'</span><span class="p">:</span> <span class="n">The</span> <span class="n">exclusion</span> <span class="n">zone</span> <span class="n">used</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'join'</span><span class="p">:</span> <span class="n">Flag</span> <span class="n">indicating</span> <span class="k">if</span> <span class="n">a</span> <span class="n">similarity</span> <span class="n">join</span> <span class="n">was</span> <span class="n">computed</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'sample_pct'</span><span class="p">:</span> <span class="n">Percentage</span> <span class="n">of</span> <span class="n">samples</span> <span class="n">used</span> <span class="ow">in</span> <span class="n">computing</span> <span class="n">the</span> <span class="n">MP</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'data'</span><span class="p">:</span> <span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'ts'</span><span class="p">:</span> <span class="n">Time</span> <span class="n">series</span> <span class="n">data</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'query'</span><span class="p">:</span> <span class="n">Query</span> <span class="n">data</span> <span class="k">if</span> <span class="n">supplied</span>
<span class="gp">>>> </span> <span class="p">}</span>
<span class="gp">>>> </span> <span class="s1">'class'</span><span class="p">:</span> <span class="s2">"MatrixProfile"</span>
<span class="gp">>>> </span> <span class="s1">'algorithm'</span><span class="p">:</span> <span class="s2">"mpx"</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-algorithms-skimp">
<h2>matrixprofile.algorithms.skimp<a class="headerlink" href="#matrixprofile-algorithms-skimp" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.algorithms.skimp">
<code class="sig-prename descclassname">matrixprofile.algorithms.</code><code class="sig-name descname">skimp</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">windows</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">show_progress</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">cross_correlation</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">pmp_obj</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">sample_pct</span><span class="o">=</span><span class="default_value">0.1</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/skimp.html#skimp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.algorithms.skimp" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the Pan Matrix Profile (PMP) for the given time series. When the
time series is only passed, windows start from 8 and increase by increments
of 2 up to length(ts) / 2. Also, the PMP is only computed using 10% of the
windows unless sample_pct is set to a different value.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>When windows is explicitly provided, sample_pct no longer takes affect. The
MP for all windows provided will be computed.</p>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series.</p></li>
<li><p><strong>show_progress</strong> (<em>bool</em><em>, </em><em>default = False</em>) – Show the progress in percent complete in increments of 5% by printing
it out to the console.</p></li>
<li><p><strong>cross_correlation</strong> (<em>bool</em><em>, </em><em>default = False</em>) – Return the MP values as Pearson Correlation instead of Euclidean
distance.</p></li>
<li><p><strong>pmp_obj</strong> (<em>dict</em><em>, </em><em>default = None</em>) – Repurpose already computed window sizes with this provided PMP. It
should be the output of a PMP algorithm such as skimp or maximum
subsequence.</p></li>
<li><p><strong>sample_pct</strong> (<em>float</em><em>, </em><em>default = 0.1</em><em> (</em><em>10%</em><em>)</em>) – Number of window sizes to compute MPs for. Decimal percent between
0 and 1.</p></li>
<li><p><strong>n_jobs</strong> (<em>int</em><em>, </em><em>Default = 1</em>) – Number of cpu cores to use.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>dict</strong> – A Pan-MatrixProfile data structure.</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'pmp'</span><span class="p">:</span> <span class="n">the</span> <span class="n">pan</span> <span class="n">matrix</span> <span class="n">profile</span> <span class="k">as</span> <span class="n">a</span> <span class="mi">2</span><span class="n">D</span> <span class="n">array</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'pmpi'</span><span class="p">:</span> <span class="n">the</span> <span class="n">pmp</span> <span class="n">indices</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'data'</span><span class="p">:</span> <span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'ts'</span><span class="p">:</span> <span class="n">time</span> <span class="n">series</span> <span class="n">used</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="p">},</span>
<span class="gp">>>> </span> <span class="s1">'windows'</span><span class="p">:</span> <span class="n">the</span> <span class="n">windows</span> <span class="n">used</span> <span class="n">to</span> <span class="n">compute</span> <span class="n">the</span> <span class="n">pmp</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'sample_pct'</span><span class="p">:</span> <span class="n">the</span> <span class="n">sample</span> <span class="n">percent</span> <span class="n">used</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'metric'</span><span class="p">:</span><span class="n">The</span> <span class="n">distance</span> <span class="n">metric</span> <span class="n">computed</span> <span class="k">for</span> <span class="n">the</span> <span class="n">pmp</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'algorithm'</span><span class="p">:</span> <span class="n">the</span> <span class="n">algorithm</span> <span class="n">used</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'class'</span><span class="p">:</span> <span class="n">PMP</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>profile</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError :</strong> – <ol class="arabic simple">
<li><p>ts is not array_like.
2. windows is not an iterable
3. show_progress is not a boolean.
4. cross_correlation is not a boolean.
5. sample_pct is not between 0 and 1.</p></li>
</ol>
</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-algorithms-mass2">
<h2>matrixprofile.algorithms.mass2<a class="headerlink" href="#matrixprofile-algorithms-mass2" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.algorithms.mass2">
<code class="sig-prename descclassname">matrixprofile.algorithms.</code><code class="sig-name descname">mass2</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">query</span></em>, <em class="sig-param"><span class="n">extras</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">threshold</span><span class="o">=</span><span class="default_value">1e-10</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/mass2.html#mass2"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.algorithms.mass2" title="Permalink to this definition">¶</a></dt>
<dd><p>Compute the distance profile for the given query over the given time
series.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to search.</p></li>
<li><p><strong>query</strong> (<em>array_like</em>) – The query.</p></li>
<li><p><strong>extras</strong> (<em>boolean</em><em>, </em><em>default False</em>) – Optionally return additional data used to compute the matrix profile.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><strong>np.array, dict</strong> – An array of distances np.array() or dict with extras.</p>
<p>With extras:</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="p">{</span>
<span class="gp">>>> </span> <span class="s1">'distance_profile'</span><span class="p">:</span> <span class="n">The</span> <span class="n">distance</span> <span class="n">profile</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'product'</span><span class="p">:</span> <span class="n">The</span> <span class="n">FFT</span> <span class="n">product</span> <span class="n">between</span> <span class="n">ts</span> <span class="ow">and</span> <span class="n">query</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'data_mean'</span><span class="p">:</span> <span class="n">The</span> <span class="n">moving</span> <span class="n">average</span> <span class="n">of</span> <span class="n">the</span> <span class="n">ts</span> <span class="n">over</span> <span class="nb">len</span><span class="p">(</span><span class="n">query</span><span class="p">),</span>
<span class="gp">>>> </span> <span class="s1">'query_mean'</span><span class="p">:</span> <span class="n">The</span> <span class="n">mean</span> <span class="n">of</span> <span class="n">the</span> <span class="n">query</span><span class="p">,</span>
<span class="gp">>>> </span> <span class="s1">'data_std'</span><span class="p">:</span> <span class="n">The</span> <span class="n">moving</span> <span class="n">std</span><span class="o">.</span> <span class="n">of</span> <span class="n">the</span> <span class="n">ts</span> <span class="n">over</span> <span class="nb">len</span><span class="p">(</span><span class="n">query</span><span class="p">),</span>
<span class="gp">>>> </span> <span class="s1">'query_std'</span><span class="p">:</span> <span class="n">The</span> <span class="n">std</span><span class="o">.</span> <span class="n">of</span> <span class="n">the</span> <span class="n">query</span>
<span class="gp">>>> </span><span class="p">}</span>
</pre></div>
</div>
</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p>distance_profile</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>ValueError</strong> – If ts is not a list or np.array.
If query is not a list or np.array.
If ts or query is not one dimensional.</p>
</dd>
</dl>
</dd></dl>
</div>
<div class="section" id="matrixprofile-algorithms-mpdist">
<h2>matrixprofile.algorithms.mpdist<a class="headerlink" href="#matrixprofile-algorithms-mpdist" title="Permalink to this headline">¶</a></h2>
<dl class="py function">
<dt id="matrixprofile.algorithms.mpdist">
<code class="sig-prename descclassname">matrixprofile.algorithms.</code><code class="sig-name descname">mpdist</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">ts</span></em>, <em class="sig-param"><span class="n">ts_b</span></em>, <em class="sig-param"><span class="n">w</span></em>, <em class="sig-param"><span class="n">threshold</span><span class="o">=</span><span class="default_value">0.05</span></em>, <em class="sig-param"><span class="n">n_jobs</span><span class="o">=</span><span class="default_value">1</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/matrixprofile/algorithms/mpdist.html#mpdist"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matrixprofile.algorithms.mpdist" title="Permalink to this definition">¶</a></dt>
<dd><p>Computes the MPDist between the two series ts and ts_b. For more details
refer to the paper:</p>
<p>Matrix Profile XII: MPdist: A Novel Time Series Distance Measure to Allow
Data Mining in More Challenging Scenarios. Shaghayegh Gharghabi,
Shima Imani, Anthony Bagnall, Amirali Darvishzadeh, Eamonn Keogh. ICDM 2018</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>array_like</em>) – The time series to compute the matrix profile for.</p></li>
<li><p><strong>ts_b</strong> (<em>array_like</em>) – The time series to compare against.</p></li>
<li><p><strong>w</strong> (<em>int</em>) – The window size.</p></li>
<li><p><strong>threshold</strong> (<em>float</em><em>, </em><em>Default 0.05</em>) – The percentile in which the distance is taken from. By default it is
set to 0.05 based on empircal research results from the paper.
Generally, you should not change this unless you know what you are
doing! This value must be a float greater than 0 and less than 1.</p></li>