-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] Optimize QUANTTransformer by using shape calculation in _fit method to avoid unnecessary computations #2727
base: main
Are you sure you want to change the base?
Conversation
Thank you for contributing to
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, but could you run this on a few datasets and endure that the output is the same still.
Ok, i'll run this on some other datasets and post the results here. |
Used this script for testing the output of the new one v/s the old one for different datasets and also different parameters. from aeon.transformations.collection.interval_based import QUANTTransformer_old, QUANTTransformer
from aeon.testing.data_generation import make_example_3d_numpy
from aeon.datasets import load_italy_power_demand, load_classification
datasets = [
("Example", make_example_3d_numpy(n_cases=10, n_channels=1, n_timepoints=12, random_state=0)[0]),
("ItalyPowerDemand", load_italy_power_demand()[0]),
("ArrowHead", load_classification("ArrowHead")[0]),
("BasicMotions", load_classification("BasicMotions")[0]),
("Beef", load_classification("Beef")[0])
]
parameter_sets = [
[2,8],[4,4],[1,2]
]
for dataset_name, X in datasets:
print(f"\nDataset: {dataset_name}")
print(f"Input shape: {X.shape}")
for params in parameter_sets:
print(f"\nParameters: interval_depth={params[0]}, quantile_divisor={params[1]}")
q = QUANTTransformer(interval_depth=params[0], quantile_divisor=params[1])
qo = QUANTTransformer_old(interval_depth=params[0], quantile_divisor=params[1])
q.fit(X)
qo.fit(X)
qt = q.transform(X)
qot = qo.transform(X)
print("Old shape:", qot.shape)
print("New shape:", qt.shape)
diff = abs(qt - qot)
if diff.max() == 0 and diff.min() == 0:
print("Values: Same")
else:
print("Values max diff:", diff.max())
print("Values mean diff:", diff.mean()) Got same result for all of them
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Reference Issues/PRs
Fixes #2722
What does this implement/fix? Explain your changes.
Used direct shape calculations for
representation_functions
in_fit
method ofQUANTTransformer
instead of unnecessary operations as only the output shapes are required to create the intervals.Does your contribution introduce a new dependency? If yes, which one?
No
Any other comments?
The output correctly matches for the example given in the docstring.
PR checklist
For all contributions
For new estimators and functions
__maintainer__
at the top of relevant files and want to be contacted regarding its maintenance. Unmaintained files may be removed. This is for the full file, and you should not add yourself if you are just making minor changes or do not want to help maintain its contents.For developers with write access