### Install Aeon Source: https://github.com/aeon-toolkit/aeon/blob/main/README.md Install the latest release of Aeon from PyPI. Use this for standard installations. ```bash pip install aeon ``` -------------------------------- ### Install aeon with dev dependencies Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/coding_standards.md Install aeon along with development dependencies, including pre-commit, to set up the development environment. ```powershell pip install --editable .[dev] ``` -------------------------------- ### Install aeon with All Stable Dependencies Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Install aeon from the GitHub main branch, including all stable dependencies, by specifying 'all_extras'. ```powershell pip install -U "aeon[all_extras] @ git+https://github.com/aeon-toolkit/aeon.git@main" ``` -------------------------------- ### Install Aeon with Optional Dependencies Source: https://github.com/aeon-toolkit/aeon/blob/main/README.md Install Aeon with all optional dependencies, including deep learning capabilities. Use this if you need advanced features. ```bash pip install aeon[all_extras] ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/coding_standards.md Install the pre-commit framework to automatically run code quality checks on commit. ```powershell pre-commit install ``` -------------------------------- ### Install tsfresh Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/tsfresh.ipynb Install the tsfresh library if it is not already installed. Uncomment the cell to run the installation. ```python # !pip install --upgrade tsfresh ``` -------------------------------- ### Install Aeon with All Extras Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/dev_installation.md Install the aeon package in editable mode, including development dependencies and all optional extras. Use this for comprehensive development. ```powershell pip install --editable .[dev,all_extras] ``` -------------------------------- ### Install Aeon with All Stable Dependencies from PyPI Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Installs the latest release of Aeon along with all stable optional dependencies using pip. This command also includes core dependencies. Note potential installation issues on macOS ARM processors. ```powershell pip install -U aeon[all_extras] ``` -------------------------------- ### Verify Aeon Installation using Pip Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Commands to verify the successful installation of Aeon. 'pip show aeon' displays installation details, while 'pip freeze' lists all installed packages in the current environment. ```powershell pip show aeon ``` ```powershell pip freeze ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/documentation.md Installs the necessary Python packages for building documentation, including Sphinx and its extensions. This command should be run from the project's root directory. ```powershell pip install --editable .[docs] ``` -------------------------------- ### Install Aeon with Core Dependencies from PyPI Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Installs the latest release of Aeon with core dependencies using pip. Recommended for most users. Ensure you are in a virtual environment. ```powershell pip install -U aeon ``` -------------------------------- ### Install Latest Development Version from GitHub Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Install the latest development version of aeon directly from the main branch on GitHub using pip. ```powershell pip install -U git+https://github.com/aeon-toolkit/aeon.git@main ``` -------------------------------- ### Load example time series datasets Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/smoothing_filters.ipynb Loads the 'airline' and 'solar' datasets for demonstration purposes. ```python # Load time series example x_airline = load_airline() x_solar = load_solar() ``` -------------------------------- ### Load and prepare example data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/tsfresh.ipynb Load the ArrowHead dataset and split it into training and testing sets. Only a subset of cases is used for faster execution. ```python X, y = load_arrow_head() n_cases = 24 X_train = X[:n_cases, :, :] y_train = y[:n_cases] X_test = X[n_cases : 2 * n_cases, :, :] y_test = y[n_cases : 2 * n_cases] print(X_train.shape, y_train.shape, X_test.shape, y_test.shape) ``` -------------------------------- ### Install Aeon with All Stable Dependencies (Quoted) Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Alternative command for installing Aeon with all stable dependencies when the shell might misinterpret special characters. Surrounding the dependency portion with quotes can resolve 'no matches found' errors. ```powershell pip install -U aeon"[all_extras]" ``` -------------------------------- ### Quick Start: Fit a Classifier Source: https://github.com/aeon-toolkit/aeon/blob/main/README.md Fit a RocketClassifier on the standard UCR Gunpoint dataset. This example demonstrates loading data, initializing a classifier, training it, and evaluating its accuracy. ```python from aeon.classification.convolution_based import RocketClassifier from aeon.datasets import load_gunpoint X_train, y_train = load_gunpoint(split="train") X_test, y_test = load_gunpoint(split="test") clf = RocketClassifier() clf.fit(X_train, y_train) print("Accuracy:", clf.score(X_test, y_test)) ``` -------------------------------- ### Load and Prepare Example Datasets Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/dictionary_based.ipynb Loads the Italy Power Demand and Basic Motions datasets, then subsets them for training and testing. This prepares data for classifier evaluation. ```python X_train, y_train = load_italy_power_demand(split="train") X_test, y_test = load_italy_power_demand(split="test") X_test = X_test[:50] y_test = y_test[:50] print(X_train.shape, y_train.shape, X_test.shape, y_test.shape) X_train_mv, y_train_mv = load_basic_motions(split="train") X_test_mv, y_test_mv = load_basic_motions(split="test") X_train_mv = X_train_mv[:20] y_train_mv = y_train_mv[:20] X_test_mv = X_test_mv[:20] y_test_mv = y_test_mv[:20] print(X_train_mv.shape, y_train_mv.shape, X_test_mv.shape, y_test_mv.shape) ``` -------------------------------- ### Importing and Generating Example Data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/base/base_classes.ipynb Imports necessary modules for classification and data generation. This example demonstrates how to import the Temporal Dictionary Ensemble classifier and a utility function to create example 3D numpy list data, which is relevant for testing collection-based estimators. ```python from aeon.classification.dictionary_based import TemporalDictionaryEnsemble from aeon.testing.data_generation import make_example_3d_numpy_list # TDE does not support unequal length collections ``` -------------------------------- ### Install Pandoc on macOS Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/documentation.md Installs Pandoc using Homebrew, a package manager for macOS, which is a dependency for building Sphinx documentation. Ensure Homebrew is installed before running this command. ```bash brew install pandoc ``` -------------------------------- ### Install Pandoc on Debian-based Systems Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/documentation.md Installs Pandoc, a universal document converter required for building documentation with Sphinx on Linux systems. This command requires superuser privileges. ```bash sudo apt install pandoc ``` -------------------------------- ### Create Environment and Install Aeon from Conda-Forge Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Creates a new conda environment named 'aeon-env' and installs Aeon from the conda-forge channel. Activates the environment for use. ```powershell conda create -n aeon-env -c conda-forge aeon conda activate aeon-env ``` -------------------------------- ### Install Numba Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/rocket.ipynb Installs or upgrades the Numba library, which is required for ROCKET compilation. ```python # !pip install --upgrade numba ``` -------------------------------- ### Verify Aeon Installation using Conda Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Commands to verify the successful installation of Aeon within a conda environment. 'conda list aeon' shows Aeon's installation details, and 'conda list' displays all installed packages. ```powershell conda list aeon ``` ```powershell conda list ``` -------------------------------- ### Example .ts File Structure Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/api_reference/data_format.md Illustrates the typical structure of a .ts file, showing the description, metadata, and data blocks. ```plaintext #The data was generated from students wearing a smart watch. #Consists of four classes, which are walking, resting, running and badminton. ... @problemName BasicMotions @timeStamps false @missing false ... @data -0.740653,-0.740653,10.208449,2.867009:-0.194301,-0.194301,-0.249618,0.516079:Standing -0.247409,-0.247409,-0.77129,-0.576154:-0.368484,-0.020851,-0.020851,-0.465607:Walking ... ``` -------------------------------- ### Load and Print Time Series Dataset Info Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/classification.ipynb Loads the ArrowHead and BasicMotions datasets and prints their types and shapes. Ensure aeon is installed. ```python import matplotlib.pyplot as plt from aeon.datasets import load_arrow_head, load_basic_motions arrow, arrow_labels = load_arrow_head(split="train") motions, motions_labels = load_basic_motions(split="train") print(f"ArrowHead series of type {type(arrow)} and shape {arrow.shape}") print(f"Motions type {type(motions)} of shape {motions_labels.shape}") ``` -------------------------------- ### WEASEL and MUSE Classification Example Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/dictionary_based.ipynb Demonstrates fitting and predicting with WEASEL for univariate time series and MUSE for multivariate time series, followed by accuracy calculation. ```python weasel = WEASEL(binning_strategy="equi-depth", anova=False, random_state=47) weasel.fit(X_train, y_train) weasel_preds = weasel.predict(X_test) print( f"Univariate WEASEL Accuracy on ItalyPowerDemand: " f"{metrics.accuracy_score(y_test, weasel_preds)}" ) muse = MUSE() muse.fit(X_train_mv, y_train_mv) muse_preds = muse.predict(X_test_mv) print( f"Multivariate MUSE Accuracy on BasicMotions: " f"{metrics.accuracy_score(y_test_mv, muse_preds)}" ) ``` -------------------------------- ### Run all unit tests locally Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/testing.md Execute all unit tests for the aeon library. Ensure development dependencies are installed. ```powershell pytest aeon/ ``` -------------------------------- ### Load Basic Motions Dataset Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/clustering/feature_based_clustering.ipynb Imports necessary libraries and loads the BasicMotions dataset for training and testing. This is a prerequisite for all subsequent clustering examples. ```python from sklearn.cluster import KMeans from aeon.clustering import TimeSeriesKMeans from aeon.clustering.feature_based import ( Catch22Clusterer, SummaryClusterer, TSFreshClusterer, ) from aeon.datasets import load_basic_motions X_train, y_train = load_basic_motions() X_test, y_test = load_basic_motions(split="test") print(X_train.shape, y_train.shape, X_test.shape, y_test.shape) ``` -------------------------------- ### Example usage of TimeSeriesKMeans with DTW distance Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/clustering/partitional_clustering.ipynb Demonstrates fitting TimeSeriesKMeans with DTW distance and mean averaging, then visualizing the clusters. Use `random_state` for deterministic results. ```python k_means = TimeSeriesKMeans( n_clusters=2, # Number of desired centers init="random", # initialisation technique: random, first or kmeans++ max_iter=10, # Maximum number of iterations for refinement on training set distance="dtw", # Distance metric to use averaging_method="mean", # Averaging technique to use random_state=1, # Makes deterministic ) k_means.fit(X_train) plot_cluster_algorithm(k_means, X_test, k_means.n_clusters) ``` -------------------------------- ### Load example dataset for unit testing Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/signature_method.ipynb Loads a pre-defined dataset suitable for unit testing classification tasks. This dataset is commonly used for evaluating model performance. ```python # Load an example dataset train_x, train_y = load_unit_test(split="train") test_x, test_y = load_unit_test(split="test") ``` -------------------------------- ### Initialize and Forecast with RegressionForecaster (Horizon 1) Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/direct.ipynb Initializes a RegressionForecaster with a horizon of 1 and a window size of 10, then makes a single prediction on the training data. This demonstrates the basic forecasting capability before applying the direct strategy. ```python from aeon.forecasting import RegressionForecaster reg = RegressionForecaster(horizon=1, window=10) reg.forecast(y_train) ``` -------------------------------- ### Uninstall Existing aeon Version Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Before installing a new version, uninstall any existing aeon installation to prevent conflicts. ```powershell pip uninstall aeon ``` -------------------------------- ### Build HTML Documentation Locally Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/documentation.md Generates the HTML version of the project documentation. This command should be executed from the 'docs' directory and will output the built files in 'docs/_build/html'. ```bash make html ``` -------------------------------- ### Build HTML Documentation Locally (Windows) Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/documentation.md Generates the HTML version of the project documentation on Windows systems. This command should be executed from the 'docs' directory and will output the built files in 'docs/_build/html'. ```bat make.bat html ``` -------------------------------- ### Run ClaSP with dominant window size and visualize Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/segmentation/segmentation_with_clasp.ipynb Applies the ClaSP segmenter using the previously determined dominant window size and visualizes the segmentation results. This demonstrates how to tune ClaSP's performance using data-driven window size selection. ```python clasp = ClaSPSegmenter(period_length=dominant_period_size, n_cps=5) found_cps = clasp.fit_predict(ts) profiles = clasp.profiles scores = clasp.scores _ = plot_series_with_profiles( ts, profiles, true_cps=true_cps, found_cps=found_cps, title="ElectricDevices", ) ``` -------------------------------- ### Initialize and Forecast with RegressionForecaster Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/iterative.ipynb Initializes a RegressionForecaster with a horizon of 1 and a window of 10, then makes a single forecast step. This forecaster uses linear regression by default. ```python from aeon.forecasting import RegressionForecaster reg = RegressionForecaster(horizon=1, window=10) p1 = reg.forecast(y_train) print(" First forecast = ", p1) ``` -------------------------------- ### Initialize TimeSeriesKMeans with kmeans++ Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/clustering/partitional_clustering.ipynb Demonstrates initializing TimeSeriesKMeans with the 'kmeans++' strategy. This method selects initial cluster centers that are likely to be further apart, potentially leading to better clustering results. ```python temp = TimeSeriesKMeans( init="kmeans++", # initialisation technique: random, or kmeans++ ) print(temp.init) ``` -------------------------------- ### Install Aeon with Quoted Dev Dependency Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/dev_installation.md Alternative method to install aeon with development dependencies, using quotes around the dependency specification. This can resolve shell interpretation issues with special characters. ```powershell pip install --editable ."[dev]" ``` -------------------------------- ### Load Data and Initialize Pipeline Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/channel_selection.ipynb Loads the BasicMotions dataset and initializes a pipeline including a channel selection transformer, Rocket transformer, and RidgeClassifierCV. Ensure necessary libraries are imported. ```python import warnings warnings.filterwarnings("ignore") from sklearn.linear_model import RidgeClassifierCV from sklearn.pipeline import make_pipeline from aeon.datasets import load_basic_motions from aeon.transformations.collection import channel_selection from aeon.transformations.collection.convolution_based import Rocket X_train, y_train = load_basic_motions(split="train") X_test, y_test = load_basic_motions(split="test") X_train.shape, X_test.shape ``` ```python # cs = channel_selection.ElbowClassSum() # ECS cs = channel_selection.ElbowClassPairwise(prototype_type="mad") # ECP ocket_pipeline = make_pipeline(cs, Rocket(), RidgeClassifierCV()) ``` -------------------------------- ### Temporal Dictionary Ensemble (TDE) Classification Example Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/dictionary_based.ipynb Shows how to initialize, fit, and predict using the Temporal Dictionary Ensemble (TDE) classifier for both univariate and multivariate time series, including an example of setting a time contract. ```python # Recommended non-contract TDE parameters tde = TemporalDictionaryEnsemble( n_parameter_samples=250, max_ensemble_size=50, randomly_selected_params=50, random_state=47, ) # If you wish to set a time contract to, for example, 5 minutes, # set time_limit_in_minutes = 5 in the constructor # Univariate tde.fit(X_train, y_train) tde_preds = tde.predict(X_test) print( "TDE Accuracy on ItalyPowerDemand: " + str(metrics.accuracy_score(y_test, tde_preds)) ) tde.fit(X_train_mv, y_train_mv) tde_preds = tde.predict(X_test_mv) print( f"TDE Accuracy on BasicMotions: " f"{metrics.accuracy_score(y_test_mv, tde_preds)}" ) ``` -------------------------------- ### Load Dataset Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/visualisation/plotting_distances.ipynb Imports the necessary function to load a dataset. This is a prerequisite for most examples. ```python from aeon.datasets import load_gunpoint ``` -------------------------------- ### Testing Utilities - Data Generation Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/api_reference/utils.md Functions for generating example data for testing. ```APIDOC ## make_example_3d_numpy ### Description Generates a 3D numpy array example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_2d_numpy_collection ### Description Generates a 2D numpy collection example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_3d_numpy_list ### Description Generates a list of 3D numpy arrays example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_2d_numpy_list ### Description Generates a list of 2D numpy arrays example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_dataframe_list ### Description Generates a list of pandas DataFrames example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_2d_dataframe_collection ### Description Generates a 2D DataFrame collection example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_multi_index_dataframe ### Description Generates a MultiIndex DataFrame example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_1d_numpy ### Description Generates a 1D numpy array example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_2d_numpy_series ### Description Generates a 2D numpy Series example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_pandas_series ### Description Generates a pandas Series example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` ```APIDOC ## make_example_dataframe_series ### Description Generates a DataFrame Series example. ### Method Not applicable (function signature) ### Endpoint Not applicable ### Parameters Not specified in source. ### Request Example Not specified in source. ### Response Not specified in source. ``` -------------------------------- ### Initialize and Fit TVP Forecaster Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/regression.ipynb Instantiate the TVP forecaster with a specified window size and fit it to the training data. ```python from aeon.forecasting.stats import TVP tvp = TVP(window=50) tvp.fit(y_train) pred = tvp.predict(y_train) ``` -------------------------------- ### Load Datasets for Visualisation Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/visualisation/plotting_for_learning_tasks.ipynb Imports and loads sample datasets, including Electric Devices Segmentation and Airline, for visualization purposes. Requires the aeon library. ```python from aeon.datasets import load_airline, load_electric_devices_segmentation ed_seg, _, ed_seg_chp = load_electric_devices_segmentation() airline = load_airline() ``` -------------------------------- ### Load and Plot Airline Data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/direct.ipynb Loads the airline dataset and visualizes the time series. Ensure aeon.visualisation is installed. ```python from aeon.datasets import load_airline from aeon.visualisation import plot_series airline = load_airline() _ = plot_series(airline) ``` -------------------------------- ### Get temporal importance curves Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/visualisation/plotting_estimators.ipynb Calculates and retrieves the temporal importance curves and their corresponding names from the trained classifier. ```python names, curves = clf.temporal_importance_curves() ``` -------------------------------- ### Load MNIST Dataset in PyTorch Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/convolution_based.ipynb Loads the MNIST dataset using PyTorch's torchvision.datasets.MNIST. Ensure you have torchvision installed. ```python import torch from torchvision import datasets, transforms # Define transformations transform = transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.1307,), (0.3081,)) ]) # Load training data rain_dataset = datasets.MNIST('../data', train=True, download=True, transform=transform) # Load test data test_dataset = datasets.MNIST('../data', train=False, download=True, transform=transform) print(f"Number of training samples: {len(train_dataset)}") print(f"Number of test samples: {len(test_dataset)}") ``` -------------------------------- ### Import Libraries and Load Data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/catch22.ipynb Imports necessary libraries and loads the ItalyPowerDemand and BasicMotions datasets. This is a prerequisite for using the Catch22 transformer. ```python import numpy as np from aeon.datasets import load_basic_motions, load_italy_power_demand from aeon.transformations.collection.feature_based import Catch22 ``` ```python IPD_X_train, IPD_y_train = load_italy_power_demand(split="train") IPD_X_test, IPD_y_test = load_italy_power_demand(split="test") print( "Italy Power Demand (Univariate): ", IPD_X_train.shape, IPD_y_train.shape, IPD_X_test.shape, IPD_y_test.shape, ) BM_X_train, BM_y_train = load_basic_motions(split="train") BM_X_test, BM_y_test = load_basic_motions(split="test") print( "Load Basic Motions (Multivarite): ", BM_X_train.shape, BM_y_train.shape, BM_X_test.shape, BM_y_test.shape, ) ``` -------------------------------- ### Load and Visualize Classification Dataset Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/similarity_search/similarity_search.ipynb Loads a classification dataset and visualizes example samples for each class. Requires matplotlib for plotting. ```python from aeon.datasets import load_classification import matplotlib.pyplot as plt import numpy as np # Load GunPoint dataset X, y = load_classification("ArrowHead") classes = np.unique(y) fig, ax = plt.subplots(figsize=(20, 5), ncols=len(classes)) for i_class, _class in enumerate(classes): for i_x in np.where(y == _class)[0][0:2]: ax[i_class].plot(X[i_x, 0], label=f"sample {i_x}") ax[i_class].legend() ax[i_class].set_title(f"class {_class}") plt.suptitle("Example samples for the GunPoint dataset") plt.show() ``` -------------------------------- ### Basic Pytest Test Function Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/testing.md A simple example of a unit test function that uses pytest to assert the output of a function. ```python def test_function(): assert function() == expected_output ``` -------------------------------- ### Load Datasets and Initialize Classifiers Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/convolution_based.ipynb Loads univariate and multivariate time series datasets and imports necessary classifiers from aeon. This sets up the environment for training and testing. ```python from sklearn.metrics import accuracy_score from aeon.classification.convolution_based import ( Arsenal, HydraClassifier, MiniRocketClassifier, MultiRocketClassifier, MultiRocketHydraClassifier, RocketClassifier, ) from aeon.datasets import load_basic_motions # multivariate dataset from aeon.datasets import load_italy_power_demand # univariate dataset italy, italy_labels = load_italy_power_demand(split="train") italy_test, italy_test_labels = load_italy_power_demand(split="test") motions, motions_labels = load_basic_motions(split="train") motions_test, motions_test_labels = load_basic_motions(split="test") italy.shape ``` -------------------------------- ### Configure TVP with Custom Variance Parameters Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/regression.ipynb Initialize a TVP forecaster with custom values for `var` and `beta_var` to control the influence of recent data and parameter uncertainty. This allows fine-tuning the model's adaptiveness. ```python tvp2 = TVP(var=1.0, beta_var=1.0, window=50) direct2 = tvp.direct_forecast(airline, prediction_horizon=12) plt.plot( np.arange(0, len(direct)), direct, label="Direct 1", color="green", linestyle=":", ) plt.plot( np.arange(0, len(direct2)), direct2, label="Direct 2", color="blue", linestyle=":", ) plt.legend() plt.xlabel("Time") plt.ylabel("Value") plt.title("Direct Forecasting with TVP") plt.show() ``` -------------------------------- ### Regression Forecaster - Basic Usage Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/forecasting.ipynb Demonstrates the basic usage of RegressionForecaster, which trains a regressor on a sliding window of the time series. It can be initialized with a specified `window` size. The `y` data must be defined. ```python from aeon.forecasting import RegressionForecaster r = RegressionForecaster(window=20) p = r.forecast(y) print(p) r2 = RegressionForecaster(window=10, horizon=5) r2.fit(y) p = r2.predict(y) print(p) ``` -------------------------------- ### Train and Predict with TimeCNNClassifier Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/deep_learning.ipynb Demonstrates training a TimeCNNClassifier on univariate and multivariate datasets and making predictions. Requires TensorFlow and aeon installed. ```python from sklearn.metrics import accuracy_score from aeon.classification.deep_learning import TimeCNNClassifier from aeon.datasets import load_basic_motions # multivariate dataset from aeon.datasets import load_italy_power_demand # univariate dataset italy, italy_labels = load_italy_power_demand(split="train") italy_test, italy_test_labels = load_italy_power_demand(split="test") motions, motions_labels = load_basic_motions(split="train") motions_test, motions_test_labels = load_basic_motions(split="train") cnn = TimeCNNClassifier(n_epochs=10) cnn.fit(italy, italy_labels) y_pred = cnn.predict(italy_test) accuracy_score(italy_test_labels, y_pred) ``` -------------------------------- ### Fit and Predict with FreshPRINCE Regressor Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/benchmarking/regression.ipynb Demonstrates fitting the FreshPRINCE regressor and making predictions on a test set. Requires training and testing data (X_train_bc, y_train_bc, X_test_bc, y_test_bc). ```python from aeon.regression import DummyRegressor from aeon.regression.feature_based import FreshPRINCERegressor fp = FreshPRINCERegressor(n_estimators=10, default_fc_parameters="minimal") fp.fit(X_train_bc, y_train_bc) y_pred_fp = fp.predict(X_test_bc) d = DummyRegressor() d.fit(X_train_bc, y_train_bc) y_pred_d = d.predict(X_test_bc) ``` -------------------------------- ### Example Usage of get_means_stds Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/similarity_search/code_speed.ipynb Demonstrates the usage of the `get_means_stds` function with a randomly generated time series and prints the shape of the resulting means. ```python rng = np.random.default_rng(12) size = 100 query_length = 10 # Create a random series with 1 feature and 'size' timesteps X = rng.random((1, size)) means, stds = get_means_stds(X, query_length) print(means.shape) ``` -------------------------------- ### Handling Soft Dependencies with Type Hints Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/adding_typehints.md Shows how to use `TYPE_CHECKING` and `from __future__ import annotations` to manage type hints for soft dependencies like the `pyod` library. This allows the code to run even if the dependency is not installed. ```python """Adapter for PyOD models""" from __future__ import annotations __maintainer__ = [] __all__ = ["PyODAdapter"] from aeon.anomaly_detection.series.base import BaseSeriesAnomalyDetector from typing import TYPE_CHECKING if TYPE_CHECKING: from pyod.models.base import BaseDetector class PyODAdapter(BaseSeriesAnomalyDetector): def __init__( self, pyod_model: BaseDetector, window_size: int = 10, stride: int = 1 ): self.pyod_model = pyod_model self.window_size = window_size self.stride = stride super().__init__(axis=0) ``` -------------------------------- ### Load Cardano Sentiment Dataset Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/benchmarking/regression.ipynb Loads a multivariate time series regression problem. Use this to get the Cardano Sentiment dataset. ```python from aeon.datasets import load_cardano_sentiment X, y = load_cardano_sentiment() X.shape ``` -------------------------------- ### Load COVID-3 Month Dataset Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/benchmarking/regression.ipynb Loads a univariate time series regression problem. Use this to get the COVID-3 Month dataset. ```python from aeon.datasets import load_covid_3month X, y = load_covid_3month() X.shape ``` -------------------------------- ### Load and Inspect Time Series Datasets Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/hybrid.ipynb Loads the 'Italy Power Demand' and 'Basic Motions' datasets for training and testing. Prints the shapes of the loaded data to verify dimensions. ```python from aeon.datasets import load_basic_motions, load_italy_power_demand X_train, y_train = load_italy_power_demand(split="train") X_test, y_test = load_italy_power_demand(split="test") X_test = X_test[:50] y_test = y_test[:50] print(X_train.shape, y_train.shape, X_test.shape, y_test.shape) X_train_mv, y_train_mv = load_basic_motions(split="train") X_test_mv, y_test_mv = load_basic_motions(split="test") print(X_train_mv.shape, y_train_mv.shape, X_test_mv.shape, y_test_mv.shape) ``` -------------------------------- ### Get Available Estimators for Classification Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/benchmarking/reference_results.ipynb Retrieves a list of all available estimators for the classification task. This is useful for understanding which models have benchmarked results. ```python from aeon.benchmarking.results_loaders import get_available_estimators get_available_estimators(task="classification") ``` -------------------------------- ### Load and Visualize Gunpoint Data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/distances/distances.ipynb Loads the Gunpoint dataset and visualizes three sample time series. Ensure Aeon and Matplotlib are installed. ```python import matplotlib.pyplot as plt import numpy as np from aeon.datasets import load_gunpoint X, y = load_gunpoint() print(X.shape) first = X[1][0] second = X[2][0] third = X[4][0] plt.plot(first, label="First series") plt.plot(second, label="Second series") plt.plot(third, label="Third series") plt.legend() print(f" class values {y[1]}, {y[2]}, {y[4]}") ``` -------------------------------- ### Basic Python Function with Type Hints Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/adding_typehints.md Demonstrates a simple Python function with type hints for its argument (a list of integers) and return value (a string). ```python from typing import List def sum_ints_return_str(int_list: List[int]) -> str: return str(sum(int_list)) ``` -------------------------------- ### Create a Python Virtual Environment (Windows/macOS) Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/installation.md Create a virtual environment named 'aeon-venv' on Windows or macOS using the python -m venv command. ```powershell python -m venv aeon-venv ``` -------------------------------- ### Import Aeon Classification and Regression Utilities Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/datasets/datasets.ipynb Imports DummyClassifier and DummyRegressor for basic supervised learning tasks. ```python import numpy as np from aeon.classification import DummyClassifier from aeon.regression import DummyRegressor ``` -------------------------------- ### Fit Estimator with Unequal Length Data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/preprocessing.ipynb Demonstrates fitting an estimator that supports unequal length series directly. `KNeighborsTimeSeriesClassifier` is an example of such an estimator. ```python from aeon.classification.distance_based import KNeighborsTimeSeriesClassifier knn = KNeighborsTimeSeriesClassifier() model = knn.fit(wii_X, wii_y) ``` -------------------------------- ### Import Classifiers and Load Data Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/classification/interval_based.ipynb Imports necessary classifiers and utility functions, then loads the ItalyPowerDemand and BasicMotions datasets for training and testing. It also filters the test data to a smaller subset for demonstration. ```python import warnings from sklearn import metrics from aeon.classification.interval_based import ( RSTSF, CanonicalIntervalForestClassifier, DrCIFClassifier, QUANTClassifier, RandomIntervalSpectralEnsembleClassifier, SupervisedTimeSeriesForest, TimeSeriesForestClassifier, ) from aeon.datasets import load_basic_motions, load_italy_power_demand from aeon.utils.discovery import all_estimators warnings.filterwarnings("ignore") all_estimators("classifier", tag_filter={"algorithm_type": "interval"}) ``` ```python X_train, y_train = load_italy_power_demand(split="train") X_test, y_test = load_italy_power_demand(split="test") X_test = X_test[:50] y_test = y_test[:50] print(X_train.shape, y_train.shape, X_test.shape, y_test.shape) X_train_mv, y_train_mv = load_basic_motions(split="train") X_test_mv, y_test_mv = load_basic_motions(split="test") X_train_mv = X_train_mv[:50] y_train_mv = y_train_mv[:50] X_test_mv = X_test_mv[:50] y_test_mv = y_test_mv[:50] print(X_train_mv.shape, y_train_mv.shape, X_test_mv.shape, y_test_mv.shape) ``` -------------------------------- ### Forecasting with Additional Series (using exog) Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/forecasting/setar.ipynb Demonstrates forecasting using SETAR-Tree with exogenous variables. The model learns patterns from both the target series (y) and additional input series (exog). Requires matplotlib and numpy for plotting. ```python import matplotlib.pyplot as plt import numpy as np from aeon.datasets import load_uschange from aeon.forecasting.machine_learning._setartree import SETARTree # Load multivariate dataset: shape should be (n_channels, n_timepoints) data = load_uschange() # y = Consumption as a 2D array with one channel; exog = the other channels y = data[0:1, :] # shape (1, T) exog = data[1:, :] # shape (C-1, T) # Split into train and test (last 8 quarters for test) along time axis (axis=1) forecast_horizon = 9 y_train = y[:, :-forecast_horizon] # (1, T-train) exog_train = exog[:, :-forecast_horizon] # (C-1, T-train) y_test = y[0, -forecast_horizon:] # (fh,) # Initialize and fit the model (axis=1 is the default for SETARTree) f_multi = SETARTree(lag=9, max_depth=40, stopping_criteria="both") f_multi.fit(y_train, exog=exog_train) # Multi-step forecast using the iterative strategy (returns shape (fh,)) preds_y = f_multi.iterative_forecast(y_train, forecast_horizon) # Plot results for y (Consumption) plt.plot(np.arange(y_train.shape[1]), y_train[0], label="Train (Consumption)") plt.plot(np.arange(y_train.shape[1], y.shape[1]), y_test, label="Test (Consumption)") plt.plot( np.arange(y_train.shape[1], y.shape[1]), preds_y, label="Forecast (Consumption)" ) plt.legend() plt.title( "SETAR-Tree Forecast with Additional Series" "\n(Consumption as y, Other Indicators as exog)" ) plt.show() ``` -------------------------------- ### AutoCorrelationSeriesTransformer Example Source: https://github.com/aeon-toolkit/aeon/blob/main/examples/transformations/transformations.ipynb Applies AutoCorrelationSeriesTransformer to a single time series to extract its autocorrelation function. Requires loading a time series dataset first. ```python from aeon.datasets import load_airline from aeon.transformations.series import AutoCorrelationSeriesTransformer series = load_airline() transformer = AutoCorrelationSeriesTransformer(n_lags=10) acf = transformer.fit_transform(series) print(acf) ``` -------------------------------- ### Time Series Clustering with KASBA Source: https://github.com/aeon-toolkit/aeon/blob/main/README.md Shows how to group similar time series from an unlabelled collection using the KASBA clustering algorithm. Requires KASBA and the load_gunpoint dataset loader. ```python from aeon.clustering import KASBA from aeon.datasets import load_gunpoint X, _ = load_gunpoint() clu = KASBA(n_clusters=2) clu.fit(X) print(clu.labels_) ``` -------------------------------- ### Directory Structure for Tests Source: https://github.com/aeon-toolkit/aeon/blob/main/docs/developer_guide/testing.md Illustrates the standard directory structure for placing test files within an aeon package. ```tree aeon/ └── package/ ├── __init__.py ├── module.py └── tests/ ├── __init__.py └── test_module.py ```