{ "cells": [ { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Early time series classification with aeon\n", "\n", "Early time series classification (eTSC) is the problem of classifying a time series after as few measurements as possible with the highest possible accuracy. The most critical issue of any eTSC method is to decide when enough data of a time series has been seen to take a decision: Waiting for more data points usually makes the classification problem easier but delays the time in which a classification is made; in contrast, earlier classification has to cope with less input data, often leading to inferior accuracy.\n", "\n", "This notebook gives a quick guide to get you started with running eTSC algorithms in aeon.\n", "\n" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Data sets and problem types\n", "The UCR/UEA [time series classification archive](https://timeseriesclassification.com/) contains a large number of example TSC problems that have been used thousands of times in the literature to assess TSC algorithms. Read the data loading documentation and notebooks for details on the aeon data formats and loading data for aeon." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false, "pycharm": { "is_executing": true } }, "outputs": [], "source": [ "# Imports used in this notebook\n", "import numpy as np\n", "\n", "from aeon.classification.early_classification._teaser import TEASER\n", "from aeon.classification.interval_based import TimeSeriesForestClassifier\n", "from aeon.datasets import load_arrow_head" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "(175, 1, 251)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Load default train/test splits from aeon/datasets/data\n", "arrow_train_X, arrow_train_y = load_arrow_head(split=\"train\")\n", "arrow_test_X, arrow_test_y = load_arrow_head(split=\"test\")\n", "\n", "arrow_test_X.shape" ] }, { "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "## Building the TEASER classifier\n", "\n", "TEASER \\[1\\] is a two-tier model using a base classifier to make predictions and a decision making estimator to decide whether these predictions are safe. As a first tier, TEASER requires a TSC algorithm, such as WEASEL, which produces class probabilities as output. As a second tier an anomaly detector is required, such as a one-class SVM." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
TEASER(classification_points=[25, 50, 75, 100, 125, 150, 175, 200, 251],\n",
" estimator=TimeSeriesForestClassifier(n_estimators=10, random_state=0),\n",
" random_state=0)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. TEASER(classification_points=[25, 50, 75, 100, 125, 150, 175, 200, 251],\n",
" estimator=TimeSeriesForestClassifier(n_estimators=10, random_state=0),\n",
" random_state=0)TimeSeriesForestClassifier(n_estimators=10, random_state=0)
TimeSeriesForestClassifier(n_estimators=10, random_state=0)