Skip to content
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] Starting Self Supervised Model with first example #2385

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

hadifawaz1999
Copy link
Member

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

TODO: add a test for TRILITE

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

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.

1 participant