|
336 | 336 | } |
337 | 337 | ], |
338 | 338 | "source": [ |
339 | | - "plt.plot(queen_df.iloc[queen_motif_index : queen_motif_index + m].values, label='Under Pressure')\n", |
340 | | - "plt.plot(vanilla_ice_df.iloc[vanilla_ice_motif_index:vanilla_ice_motif_index+m].values, label='Ice Ice Baby')\n", |
| 339 | + "queen_z_norm_motif = core.z_norm(queen_df.iloc[queen_motif_index : queen_motif_index + m].values)\n", |
| 340 | + "vanilla_ice_z_norm_motif = core.z_norm(vanilla_ice_df.iloc[vanilla_ice_motif_index:vanilla_ice_motif_index+m].values)\n", |
| 341 | + "\n", |
| 342 | + "plt.plot(queen_z_norm_motif, label='Under Pressure')\n", |
| 343 | + "plt.plot(vanilla_ice_z_norm_motif, label='Ice Ice Baby')\n", |
341 | 344 | "\n", |
342 | 345 | "plt.xlabel('Time')\n", |
343 | 346 | "plt.ylabel('Frequency')\n", |
|
347 | 350 | "plt.show()" |
348 | 351 | ] |
349 | 352 | }, |
| 353 | + { |
| 354 | + "cell_type": "markdown", |
| 355 | + "metadata": {}, |
| 356 | + "source": [ |
| 357 | + "[comment]: <> (Myst)\n", |
| 358 | + ":::{admonition} **Z-normalizing Your Subsequences Before Plotting**\n", |
| 359 | + ":class: note\n", |
| 360 | + "\n", |
| 361 | + "By default, `stumpy` z-normalizes **all** subsequences before comparing their matrix profile distances (i.e., `normalize=True`). Thus, before we visualize the matching subsequences, we must also z-normalize them first. Failure to do so would result in subsequences being plotted with non-normalized amplitudes. Subsequence z-normalization can be easily accomplished by using the `core.z_norm` helper function:\n", |
| 362 | + "\n", |
| 363 | + "```\n", |
| 364 | + "from stumpy import core\n", |
| 365 | + "\n", |
| 366 | + "core.z_norm(T[idx : idx + m])\n", |
| 367 | + "```\n", |
| 368 | + "\n", |
| 369 | + "However, this z-normalization step should be omitted whenever the `normalize` parameter has been set to `False` when computing matrix profile distances.\n", |
| 370 | + ":::" |
| 371 | + ] |
| 372 | + }, |
350 | 373 | { |
351 | 374 | "cell_type": "markdown", |
352 | 375 | "metadata": {}, |
|
385 | 408 | "name": "python", |
386 | 409 | "nbconvert_exporter": "python", |
387 | 410 | "pygments_lexer": "ipython3", |
388 | | - "version": "3.12.3" |
| 411 | + "version": "3.12.4" |
389 | 412 | } |
390 | 413 | }, |
391 | 414 | "nbformat": 4, |
|
0 commit comments