Repository navigation
[BUG] Normalize multichannel shapelet distance plots - #4022
austinchennn wants to merge 1 commit into
Conversation
Thank you for contributing to
|
|
CI note for the current head |
|
Hey, thanks for looking into this, could you provide some example plots so we can visualize the changes on the output ? From memory at the time of the original issue the multivariate plots were messy and not very informative, would just like to see how the PR improves on this with the new normalization you introduce. |
|
Thanks for taking a look! I'll add example plots here — a two-channel, four-point shapelet case (where the old code raised the broadcasting error) and a square case where channels == shapelet length (where it silently plotted wrong distances), plus the univariate control for comparison. Give me a bit to generate them and I'll post them on this PR. |
|
Thanks for the review. Here are actual before/after calls to
Both cases use Exact numeric results. Reproduction data for either channel count: rng = np.random.RandomState(42)
values = rng.normal(size=(n_channels, 4))
X = rng.normal(size=(n_channels, 10))
X[:, 1:9:2] = values * (np.arange(1, n_channels + 1)[:, None] + 1) + (np.arange(n_channels)[:, None] + 3)
ShapeletVisualizer(values, normalise=True, dilation=2).plot_distance_vector(X, show_legend=False, show_threshold=False)This remains a narrow runtime fix for |


Reference Issues/PRs
Addresses the normalization/broadcasting error reported in #3028. The broader shapelet interpretation/documentation questions in that issue remain open.
What does this implement/fix? Explain your changes.
ShapeletVisualizer.plot_distance_vectoraccepts channel-by-time arrays but drops the channel axis when computing the shapelet's mean and standard deviation. For a normalized two-channel, four-point shapelet it raises a broadcasting error. When the channel count equals the shapelet length, broadcasting instead succeeds along the wrong axis and the plotted distances are incorrect.Keep the reduced time axis in both statistics, matching the per-channel normalization already used by
plot_on_X. The subsequence/distance helpers and classifier visualizer's explicit univariate restriction are unchanged.Add numerical regression coverage for one, two and four channels; normalized and raw distances; and newly created figures versus supplied axes. The reference distances use independent row-wise normalization and NumPy norms of dilated windows, and validate the actual plotted line rather than only the return type.
Does your contribution introduce a new dependency? If yes, which one?
No. Matplotlib remains the existing optional plotting dependency; the tests follow the module's Agg backend and optional-dependency guard.
Any other comments?
Validation on macOS arm64, Python 3.11.15:
git diff --checkpass.I checked all 86 open PR file lists. #3842 touches the same production module only to relocate helper imports; it does not change this normalization or test file.
PR checklist
For all contributions
This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.