diff --git a/dtw_minwarp.ipynb b/dtw_minwarp.ipynb index 67ea413016a247048400a540d4007751be3c5818..0edfcb6659251dd51d653a144cb58d16f2ed7049 100644 --- a/dtw_minwarp.ipynb +++ b/dtw_minwarp.ipynb @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 29, "metadata": { "editable": true, "slideshow": { @@ -73,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -125,10 +125,8 @@ "y_1_rs = y_1.reshape(-1,1)\n", "y_2_rs = y_2.reshape(-1,1)\n", " \n", - "if True: # <--- you get the idea... yes you do\n", - " plt.plot(y_1) \n", - " plt.plot(y_2)\n", - " plt.pause(0.1)" + "plt.plot(y_1) \n", + "plt.plot(y_2); # the semicolon prevents printing the output of the last command" ] }, { @@ -142,14 +140,14 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "computation time DTW 1 = 0.0007109642028808594\n" + "computation time of DTW 1 = 0.0006000995635986328\n" ] }, { @@ -168,15 +166,14 @@ "\n", "tic = time()\n", "optimal_path_1, dtw_score_1 = dtw_path(y_1, y_2)\n", - "print('computation time DTW 1 = '+str(time()-tic))\n", + "print('computation time of DTW 1 = '+str(time()-tic))\n", "\n", "op_1_x = [col[0] for col in optimal_path_1]\n", "op_1_y = [col[1] for col in optimal_path_1]\n", "\n", - "if True:\n", - " plt.imshow(dm_1.T, origin='lower')\n", - " plt.plot(op_1_x, op_1_y, ':w')\n", - " plt.title('DTW 1 = '+str(round(dtw_score_1,3)))" + "plt.imshow(dm_1.T, origin='lower')\n", + "plt.plot(op_1_x, op_1_y, ':w')\n", + "plt.title('DTW 1 = '+str(round(dtw_score_1,3)));" ] }, { @@ -197,15 +194,15 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 32, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "computation time DTW 2 = 0.014889001846313477\n", - "computation time classical optimal path = 0.009966850280761719\n" + "computation time of DTW 2 = 0.005923032760620117\n", + "computation time of classical optimal path = 0.002828836441040039\n" ] }, { @@ -261,17 +258,15 @@ " \n", " optimal_path_2.append([i,j])\n", "\n", - "print('computation time DTW 2 = '+str(time()-tic))\n", - "print('computation time classical optimal path = '+str(time()-tic_1))\n", + "print('computation time of DTW 2 = '+str(time()-tic))\n", + "print('computation time of classical optimal path = '+str(time()-tic_1))\n", "\n", "op_2_x = [col[0] for col in optimal_path_2]\n", "op_2_y = [col[1] for col in optimal_path_2]\n", "\n", - "if True:\n", - " plt.imshow(dm_2.T, origin='lower')\n", - " plt.plot(op_2_x, op_2_y, ':w')\n", - " plt.title('DTW 2 = '+str(round(dtw_score_2,3)))\n", - " " + "plt.imshow(dm_2.T, origin='lower')\n", + "plt.plot(op_2_x, op_2_y, ':w')\n", + "plt.title('DTW 2 = '+str(round(dtw_score_2,3)));" ] }, { @@ -283,14 +278,14 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "computation time minimum optimal path = 0.0037178993225097656\n" + "computation time minimum of optimal path = 0.006082773208618164\n" ] }, { @@ -341,16 +336,15 @@ " \n", " optimal_path_3.append([i,j])\n", "\n", - "print('computation time minimum optimal path = '+str(time()-tic))\n", + "print('computation time minimum of optimal path = '+str(time()-tic))\n", "\n", "op_3_x = [col[0] for col in optimal_path_3]\n", "op_3_y = [col[1] for col in optimal_path_3]\n", "\n", - "if True:\n", - " plt.imshow(dm_2.T, origin='lower')\n", - " plt.plot(op_2_x, op_2_y, ':w')\n", - " plt.plot(op_3_x, op_3_y, ':r', linewidth=2)\n", - " plt.title('DTW 2 = '+str(round(dtw_score_2,3)))" + "plt.imshow(dm_2.T, origin='lower')\n", + "plt.plot(op_2_x, op_2_y, ':w')\n", + "plt.plot(op_3_x, op_3_y, ':r', linewidth=2)\n", + "plt.title('DTW 2 = '+str(round(dtw_score_2,3)));" ] }, {