Skip to content

[ENH] Starting Self Supervised Model with first example #2385

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

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

hadifawaz1999
Copy link
Member

@hadifawaz1999 hadifawaz1999 commented Nov 24, 2024

Adding the SSL submodule in transformations collection with no base class for now, adding more examples i will see if a base is needed

Started by adding TRILITE first example

Usage:

from aeon.transformations.collection.self_supervised import TRILITE
from aeon.networks import FCNNetwork
from aeon.classification.distance_based import KNeighborsTimeSeriesClassifier
from aeon.datasets import load_unit_test

if __name__ == '__main__':
    X_train, y_train = load_unit_test(split="train")
    X_test, y_test = load_unit_test(split="test")
    
    net = FCNNetwork(n_layers=1,n_filters=2,kernel_size=2)
    
    ssl = TRILITE(backbone_network=net, latent_space_dim=2, n_epochs=3,
                  verbose=True,
                  save_best_model=True)
    ssl.fit(X_train)
    
    X_train_transformed = ssl.transform(X_train)
    X_test_transformed = ssl.transform(X_test)
    
    nn = KNeighborsTimeSeriesClassifier(distance="euclidean")
    nn.fit(X_train_transformed, y_train)
    y_pred = nn.predict(X_test_transformed)
    
    ssl_loaded = TRILITE(latent_space_dim=2)
    ssl_loaded.load_model("./best_model.keras")
    
    X_train_transformed = ssl_loaded.transform(X_train)
    X_test_transformed = ssl_loaded.transform(X_test)
    
    nn = KNeighborsTimeSeriesClassifier(distance="euclidean")
    nn.fit(X_train_transformed, y_train)
    y_pred = nn.predict(X_test_transformed)

@aeon-actions-bot aeon-actions-bot bot added enhancement New feature, improvement request or other non-bug code enhancement transformations Transformations package labels Nov 24, 2024
@aeon-actions-bot
Copy link
Contributor

Thank you for contributing to aeon

I have added the following labels to this PR based on the title: [ $\color{#FEF1BE}{\textsf{enhancement}}$ ].
I have added the following labels to this PR based on the changes made: [ $\color{#41A8F6}{\textsf{transformations}}$ ]. Feel free to change these if they do not properly represent the PR.

The Checks tab will show the status of our automated tests. You can click on individual test runs in the tab or "Details" in the panel below to see more information if there is a failure.

If our pre-commit code quality check fails, any trivial fixes will automatically be pushed to your PR unless it is a draft.

Don't hesitate to ask questions on the aeon Slack channel if you have any.

PR CI actions

These checkboxes will add labels to enable/disable CI functionality for this PR. This may not take effect immediately, and a new commit may be required to run the new configuration.

  • Run pre-commit checks for all files
  • Run mypy typecheck tests
  • Run all pytest tests and configurations
  • Run all notebook example tests
  • Run numba-disabled codecov tests
  • Stop automatic pre-commit fixes (always disabled for drafts)
  • Disable numba cache loading
  • Push an empty commit to re-run CI checks

@hadifawaz1999 hadifawaz1999 marked this pull request as ready for review May 16, 2025 17:11
@hadifawaz1999
Copy link
Member Author

For some reason after the fix @MatthewMiddlehurst its raisins this

FAILED aeon/testing/tests/test_all_estimators.py::test_all_estimators[check_fit_updates_state_and_cloning(estimator=TRILITE(backbone_network=FCNNetwork(n_layers=1,n_filters=2,kernel_size=2),latent_space_dim=2,n_epochs=3),datatype=EqualLengthUnivariate-Classification-numpy3D)] - AssertionError: Estimator TRILITE should not change or mutate the parameter backbone_network from FCNNetwork(n_layers=1, n_filters=2, kernel_size=2) to FCNNetwork(n_layers=1, n_filters=2, kernel_size=2) during fit.

Even though its not being overridden in fit

@TonyBagnall
Copy link
Contributor

@hadifawaz1999 do you want this to be an experimental module?

@hadifawaz1999
Copy link
Member Author

@hadifawaz1999 do you want this to be an experimental module?

yes of course as it might change a lot, but i wasn't sure where should i commit a change to mention that

@hadifawaz1999 hadifawaz1999 requested a review from TonyBagnall May 29, 2025 14:30
@TonyBagnall
Copy link
Contributor

@hadifawaz1999 do you want this to be an experimental module?

yes of course as it might change a lot, but i wasn't sure where should i commit a change to mention that

add it to readme and somehwere else, dont it for imbalance here #2498

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature, improvement request or other non-bug code enhancement transformations Transformations package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants