|
262 | 262 | "\n", |
263 | 263 | "### The Performance\n", |
264 | 264 | "\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:" |
266 | 266 | ] |
267 | 267 | }, |
268 | 268 | { |
|
274 | 274 | "name": "stdout", |
275 | 275 | "output_type": "stream", |
276 | 276 | "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" |
279 | 279 | ] |
280 | 280 | } |
281 | 281 | ], |
282 | 282 | "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", |
286 | 286 | "\n", |
287 | 287 | "# `stumpy.stump` timing\n", |
288 | 288 | "start = time.time()\n", |
289 | 289 | "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", |
291 | 291 | " T_stream = np.append(T_stream, T_full[i])\n", |
292 | 292 | " mp = stumpy.stump(T_stream, m)\n", |
293 | 293 | "stump_time = time.time() - start\n", |
294 | 294 | "\n", |
295 | 295 | "# `stumpy.stumpi` timing\n", |
296 | 296 | "stream = stumpy.stumpi(T_stream, m, egress=False) # Don't egress/remove the oldest data point when streaming\n", |
297 | 297 | "start = time.time()\n", |
298 | | - "for i in range(200, len(T_full)):\n", |
| 298 | + "for i in range(20, len(T_full)):\n", |
299 | 299 | " t = T_full[i]\n", |
300 | 300 | " stream.update(t)\n", |
301 | 301 | "stumpi_time = time.time() - start\n", |
|
338 | 338 | "name": "stdout", |
339 | 339 | "output_type": "stream", |
340 | 340 | "text": [ |
341 | | - "stumpy.stumpi: 13.5s\n" |
| 341 | + "stumpy.stumpi: 0.3s\n" |
342 | 342 | ] |
343 | 343 | } |
344 | 344 | ], |
|
765 | 765 | "</style>\n", |
766 | 766 | "\n", |
767 | 767 | "<div class=\"animation\">\n", |
768 | | - " <img id=\"_anim_img1e93c6dd911e4fc0a2f799828d5ca19d\">\n", |
| 768 | + " <img id=\"_anim_imga55b011d02734fd39f65ee611c7e77c5\">\n", |
769 | 769 | " <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", |
771 | 771 | " 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", |
773 | 773 | " <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", |
775 | 775 | " <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", |
777 | 777 | " <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", |
779 | 779 | " <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", |
781 | 781 | " <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", |
783 | 783 | " <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", |
785 | 785 | " <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", |
787 | 787 | " <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", |
789 | 789 | " <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", |
791 | 791 | " <i class=\"fa fa-plus\"></i></button>\n", |
792 | 792 | " </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", |
794 | 794 | " 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", |
796 | 796 | " 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", |
799 | 799 | " >\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", |
802 | 802 | " >\n", |
803 | | - " <label for=\"_anim_radio3_1e93c6dd911e4fc0a2f799828d5ca19d\">Reflect</label>\n", |
| 803 | + " <label for=\"_anim_radio3_a55b011d02734fd39f65ee611c7e77c5\">Reflect</label>\n", |
804 | 804 | " </form>\n", |
805 | 805 | " </div>\n", |
806 | 806 | "</div>\n", |
|
810 | 810 | " /* Instantiate the Animation class. */\n", |
811 | 811 | " /* The IDs given should match those used in the template above. */\n", |
812 | 812 | " (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", |
816 | 816 | " var frames = new Array(153);\n", |
817 | 817 | " \n", |
818 | 818 | " frames[0] = \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAB9AAAAJYCAYAAAA6431rAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90\\\n", |
@@ -266127,7 +266127,7 @@ |
266127 | 266127 | " /* set a timeout to make sure all the above elements are created before\n", |
266128 | 266128 | " the object is initialized. */\n", |
266129 | 266129 | " 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", |
266131 | 266131 | " loop_select_id);\n", |
266132 | 266132 | " }, 0);\n", |
266133 | 266133 | " })()\n", |
@@ -266221,22 +266221,22 @@ |
266221 | 266221 | "name": "stdout", |
266222 | 266222 | "output_type": "stream", |
266223 | 266223 | "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" |
266240 | 266240 | ] |
266241 | 266241 | } |
266242 | 266242 | ], |
|
0 commit comments