Skip to content

Commit f8e128e

Browse files
committed
Reduced execution time in streaming tutorial
1 parent 616f092 commit f8e128e

1 file changed

Lines changed: 48 additions & 48 deletions

File tree

docs/Tutorial_Matrix_Profiles_For_Streaming_Data.ipynb

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
"\n",
263263
"### The Performance\n",
264264
"\n",
265-
"We've basically claimed that incrementally updating our matrix profile with `stumpy.stumpi` is much faster (in total computational time) than performing a full pairwise distance calculation with `stumpy.stump` as each new data point arrives. Let's actually compare the timings by taking a full time series that is 10,000 data points in length and we initialize both approaches with the first 2% of the time series (i.e., the first 200 points) and append a single new data point at each iteration before re-computing the matrix profile:"
265+
"We've basically claimed that incrementally updating our matrix profile with `stumpy.stumpi` is much faster (in total computational time) than performing a full pairwise distance calculation with `stumpy.stump` as each new data point arrives. Let's actually compare the timings by taking a full time series that is 1,000 data points in length and we initialize both approaches with the first 2% of the time series (i.e., the first 20 points) and append a single new data point at each iteration before re-computing the matrix profile:"
266266
]
267267
},
268268
{
@@ -274,28 +274,28 @@
274274
"name": "stdout",
275275
"output_type": "stream",
276276
"text": [
277-
"stumpy.stump: 314.9s\n",
278-
"stumpy.stumpi: 16.7s\n"
277+
"stumpy.stump: 4.5s\n",
278+
"stumpy.stumpi: 0.4s\n"
279279
]
280280
}
281281
],
282282
"source": [
283-
"T_full = np.random.rand(10_000)\n",
284-
"T_stream = T_full[:200].copy()\n",
285-
"m = 100\n",
283+
"T_full = np.random.rand(1_000)\n",
284+
"T_stream = T_full[:20].copy()\n",
285+
"m = 10\n",
286286
"\n",
287287
"# `stumpy.stump` timing\n",
288288
"start = time.time()\n",
289289
"mp = stumpy.stump(T_stream, m)\n",
290-
"for i in range(200, len(T_full)):\n",
290+
"for i in range(20, len(T_full)):\n",
291291
" T_stream = np.append(T_stream, T_full[i])\n",
292292
" mp = stumpy.stump(T_stream, m)\n",
293293
"stump_time = time.time() - start\n",
294294
"\n",
295295
"# `stumpy.stumpi` timing\n",
296296
"stream = stumpy.stumpi(T_stream, m, egress=False) # Don't egress/remove the oldest data point when streaming\n",
297297
"start = time.time()\n",
298-
"for i in range(200, len(T_full)):\n",
298+
"for i in range(20, len(T_full)):\n",
299299
" t = T_full[i]\n",
300300
" stream.update(t)\n",
301301
"stumpi_time = time.time() - start\n",
@@ -338,7 +338,7 @@
338338
"name": "stdout",
339339
"output_type": "stream",
340340
"text": [
341-
"stumpy.stumpi: 13.5s\n"
341+
"stumpy.stumpi: 0.3s\n"
342342
]
343343
}
344344
],
@@ -765,42 +765,42 @@
765765
"</style>\n",
766766
"\n",
767767
"<div class=\"animation\">\n",
768-
" <img id=\"_anim_img1e93c6dd911e4fc0a2f799828d5ca19d\">\n",
768+
" <img id=\"_anim_imga55b011d02734fd39f65ee611c7e77c5\">\n",
769769
" <div class=\"anim-controls\">\n",
770-
" <input id=\"_anim_slider1e93c6dd911e4fc0a2f799828d5ca19d\" type=\"range\" class=\"anim-slider\"\n",
770+
" <input id=\"_anim_slidera55b011d02734fd39f65ee611c7e77c5\" type=\"range\" class=\"anim-slider\"\n",
771771
" name=\"points\" min=\"0\" max=\"1\" step=\"1\" value=\"0\"\n",
772-
" oninput=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.set_frame(parseInt(this.value));\">\n",
772+
" oninput=\"anima55b011d02734fd39f65ee611c7e77c5.set_frame(parseInt(this.value));\">\n",
773773
" <div class=\"anim-buttons\">\n",
774-
" <button title=\"Decrease speed\" aria-label=\"Decrease speed\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.slower()\">\n",
774+
" <button title=\"Decrease speed\" aria-label=\"Decrease speed\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.slower()\">\n",
775775
" <i class=\"fa fa-minus\"></i></button>\n",
776-
" <button title=\"First frame\" aria-label=\"First frame\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.first_frame()\">\n",
776+
" <button title=\"First frame\" aria-label=\"First frame\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.first_frame()\">\n",
777777
" <i class=\"fa fa-fast-backward\"></i></button>\n",
778-
" <button title=\"Previous frame\" aria-label=\"Previous frame\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.previous_frame()\">\n",
778+
" <button title=\"Previous frame\" aria-label=\"Previous frame\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.previous_frame()\">\n",
779779
" <i class=\"fa fa-step-backward\"></i></button>\n",
780-
" <button title=\"Play backwards\" aria-label=\"Play backwards\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.reverse_animation()\">\n",
780+
" <button title=\"Play backwards\" aria-label=\"Play backwards\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.reverse_animation()\">\n",
781781
" <i class=\"fa fa-play fa-flip-horizontal\"></i></button>\n",
782-
" <button title=\"Pause\" aria-label=\"Pause\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.pause_animation()\">\n",
782+
" <button title=\"Pause\" aria-label=\"Pause\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.pause_animation()\">\n",
783783
" <i class=\"fa fa-pause\"></i></button>\n",
784-
" <button title=\"Play\" aria-label=\"Play\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.play_animation()\">\n",
784+
" <button title=\"Play\" aria-label=\"Play\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.play_animation()\">\n",
785785
" <i class=\"fa fa-play\"></i></button>\n",
786-
" <button title=\"Next frame\" aria-label=\"Next frame\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.next_frame()\">\n",
786+
" <button title=\"Next frame\" aria-label=\"Next frame\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.next_frame()\">\n",
787787
" <i class=\"fa fa-step-forward\"></i></button>\n",
788-
" <button title=\"Last frame\" aria-label=\"Last frame\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.last_frame()\">\n",
788+
" <button title=\"Last frame\" aria-label=\"Last frame\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.last_frame()\">\n",
789789
" <i class=\"fa fa-fast-forward\"></i></button>\n",
790-
" <button title=\"Increase speed\" aria-label=\"Increase speed\" onclick=\"anim1e93c6dd911e4fc0a2f799828d5ca19d.faster()\">\n",
790+
" <button title=\"Increase speed\" aria-label=\"Increase speed\" onclick=\"anima55b011d02734fd39f65ee611c7e77c5.faster()\">\n",
791791
" <i class=\"fa fa-plus\"></i></button>\n",
792792
" </div>\n",
793-
" <form title=\"Repetition mode\" aria-label=\"Repetition mode\" action=\"#n\" name=\"_anim_loop_select1e93c6dd911e4fc0a2f799828d5ca19d\"\n",
793+
" <form title=\"Repetition mode\" aria-label=\"Repetition mode\" action=\"#n\" name=\"_anim_loop_selecta55b011d02734fd39f65ee611c7e77c5\"\n",
794794
" class=\"anim-state\">\n",
795-
" <input type=\"radio\" name=\"state\" value=\"once\" id=\"_anim_radio1_1e93c6dd911e4fc0a2f799828d5ca19d\"\n",
795+
" <input type=\"radio\" name=\"state\" value=\"once\" id=\"_anim_radio1_a55b011d02734fd39f65ee611c7e77c5\"\n",
796796
" checked>\n",
797-
" <label for=\"_anim_radio1_1e93c6dd911e4fc0a2f799828d5ca19d\">Once</label>\n",
798-
" <input type=\"radio\" name=\"state\" value=\"loop\" id=\"_anim_radio2_1e93c6dd911e4fc0a2f799828d5ca19d\"\n",
797+
" <label for=\"_anim_radio1_a55b011d02734fd39f65ee611c7e77c5\">Once</label>\n",
798+
" <input type=\"radio\" name=\"state\" value=\"loop\" id=\"_anim_radio2_a55b011d02734fd39f65ee611c7e77c5\"\n",
799799
" >\n",
800-
" <label for=\"_anim_radio2_1e93c6dd911e4fc0a2f799828d5ca19d\">Loop</label>\n",
801-
" <input type=\"radio\" name=\"state\" value=\"reflect\" id=\"_anim_radio3_1e93c6dd911e4fc0a2f799828d5ca19d\"\n",
800+
" <label for=\"_anim_radio2_a55b011d02734fd39f65ee611c7e77c5\">Loop</label>\n",
801+
" <input type=\"radio\" name=\"state\" value=\"reflect\" id=\"_anim_radio3_a55b011d02734fd39f65ee611c7e77c5\"\n",
802802
" >\n",
803-
" <label for=\"_anim_radio3_1e93c6dd911e4fc0a2f799828d5ca19d\">Reflect</label>\n",
803+
" <label for=\"_anim_radio3_a55b011d02734fd39f65ee611c7e77c5\">Reflect</label>\n",
804804
" </form>\n",
805805
" </div>\n",
806806
"</div>\n",
@@ -810,9 +810,9 @@
810810
" /* Instantiate the Animation class. */\n",
811811
" /* The IDs given should match those used in the template above. */\n",
812812
" (function() {\n",
813-
" var img_id = \"_anim_img1e93c6dd911e4fc0a2f799828d5ca19d\";\n",
814-
" var slider_id = \"_anim_slider1e93c6dd911e4fc0a2f799828d5ca19d\";\n",
815-
" var loop_select_id = \"_anim_loop_select1e93c6dd911e4fc0a2f799828d5ca19d\";\n",
813+
" var img_id = \"_anim_imga55b011d02734fd39f65ee611c7e77c5\";\n",
814+
" var slider_id = \"_anim_slidera55b011d02734fd39f65ee611c7e77c5\";\n",
815+
" var loop_select_id = \"_anim_loop_selecta55b011d02734fd39f65ee611c7e77c5\";\n",
816816
" var frames = new Array(153);\n",
817817
" \n",
818818
" frames[0] = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAJYCAYAAAA6431rAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90\\\n",
@@ -266127,7 +266127,7 @@
266127266127
" /* set a timeout to make sure all the above elements are created before\n",
266128266128
" the object is initialized. */\n",
266129266129
" setTimeout(function() {\n",
266130-
" anim1e93c6dd911e4fc0a2f799828d5ca19d = new Animation(frames, img_id, slider_id, 100.0,\n",
266130+
" anima55b011d02734fd39f65ee611c7e77c5 = new Animation(frames, img_id, slider_id, 100.0,\n",
266131266131
" loop_select_id);\n",
266132266132
" }, 0);\n",
266133266133
" })()\n",
@@ -266221,22 +266221,22 @@
266221266221
"name": "stdout",
266222266222
"output_type": "stream",
266223266223
"text": [
266224-
"Full Matrix Profile: [2.43 2.73 2.83 3.18 2.42 1.46 1.57 0.78 1.17 1.26 1.42 1.93 2.85 2.4\n",
266225-
" 2.48 2.33 1.64 1.58 1.76 1.97 2.58 2.43 2.23 2.21 1.58 1.76 1.97 2.34\n",
266226-
" 1.93 2.22 2.4 1.57 0.78 1.17 1.26 1.55 1.38 1.92 2.1 1.46 1.97 1.65\n",
266227-
" 1.55 1.38 2.06 2.38 2.21 2.4 1.84 2.26 1.64 2.12 2.22 2.05 1.97 1.57\n",
266228-
" 1.42]\n",
266229-
"Left Matrix Profile: [ inf inf inf 3.35 3.03 3.44 3.71 3.97 3.35 2.81 3.38 3.39 4.01 4.01\n",
266230-
" 2.58 2.33 2.61 2.9 2.52 2.68 3.18 2.43 2.23 2.66 1.58 1.76 1.97 2.58\n",
266231-
" 1.93 2.42 2.4 1.57 0.78 1.17 1.26 2.44 2.81 2.34 2.1 1.46 2.01 1.65\n",
266232-
" 1.55 1.38 2.06 2.38 2.21 2.4 1.84 2.26 1.64 2.12 2.22 2.05 1.97 1.57\n",
266233-
" 1.42]\n",
266234-
"Full Matrix Profile Indices: [21 25 26 37 29 39 31 32 33 34 56 28 29 30 31 7 50 24 25 26 27 0 5 46\n",
266235-
" 17 18 19 37 11 52 13 6 7 8 9 42 43 56 8 5 54 34 35 36 37 28 23 24\n",
266236-
" 25 26 16 28 29 32 40 36 10]\n",
266237-
"Left Matrix Profile Indices: [-1 -1 -1 0 0 0 1 2 0 5 5 7 8 5 6 7 11 9 5 6 7 0 5 6\n",
266238-
" 17 18 19 20 11 4 13 6 7 8 9 10 19 10 8 5 33 34 35 36 37 28 23 24\n",
266239-
" 25 26 16 28 29 32 40 36 10]\n"
266224+
"Full Matrix Profile: [1.86 1.75 2.11 1.91 1.76 1.93 2.3 2.03 2.14 2.41 1.66 1.56 1.61 2.11\n",
266225+
" 2.04 1.92 1.73 2.02 2.05 2.32 2.32 1.53 1.61 2.11 2.42 2.2 2.04 1.53\n",
266226+
" 1.52 1.94 1.95 1.76 2.05 1.52 1.94 1.95 1.66 1.56 2.05 2.28 2.04 1.86\n",
266227+
" 1.75 2.11 1.77 1.84 2.02 2.08 2.08 2.51 2.45 2.04 1.77 1.76 1.93 1.76\n",
266228+
" 2.1 ]\n",
266229+
"Left Matrix Profile: [ inf inf inf 2.67 3.46 2.4 2.3 2.84 2.81 2.91 2.75 2.61 2.92 2.41\n",
266230+
" 2.09 1.92 1.73 2.65 3.1 3.28 2.92 2.9 1.61 2.11 2.74 2.86 2.38 1.53\n",
266231+
" 2.12 2.02 2.2 2.28 2.05 1.52 1.94 1.95 1.66 1.56 2.05 2.28 2.04 1.86\n",
266232+
" 1.75 2.11 2.21 1.84 2.02 2.08 2.08 2.51 2.45 2.04 1.77 1.76 1.93 1.76\n",
266233+
" 2.1 ]\n",
266234+
"Full Matrix Profile Indices: [41 42 43 52 53 54 1 33 34 13 36 37 22 23 51 11 12 46 38 54 55 27 12 13\n",
266235+
" 51 30 40 21 33 34 35 55 27 28 29 30 10 11 18 13 26 0 1 2 52 1 17 36\n",
266236+
" 37 8 39 14 44 4 5 31 32]\n",
266237+
"Left Matrix Profile Indices: [-1 -1 -1 0 1 0 1 2 3 4 2 3 4 9 10 11 12 13 0 15 16 17 12 13\n",
266238+
" 14 1 14 21 4 5 25 26 27 28 29 30 10 11 18 13 26 0 1 2 3 1 17 36\n",
266239+
" 37 8 39 14 44 4 5 31 32]\n"
266240266240
]
266241266241
}
266242266242
],

0 commit comments

Comments
 (0)