CINXE.COM
tsai
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> <meta charset="utf-8"> <meta name="generator" content="quarto-1.6.42"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes"> <title>tsai</title> <style> code{white-space: pre-wrap;} span.smallcaps{font-variant: small-caps;} div.columns{display: flex; gap: min(4vw, 1.5em);} div.column{flex: auto; overflow-x: auto;} div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} ul.task-list{list-style: none;} ul.task-list li input[type="checkbox"] { width: 0.8em; margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ vertical-align: middle; } /* CSS for syntax highlighting */ pre > code.sourceCode { white-space: pre; position: relative; } pre > code.sourceCode > span { line-height: 1.25; } pre > code.sourceCode > span:empty { height: 1.2em; } .sourceCode { overflow: visible; } code.sourceCode > span { color: inherit; text-decoration: inherit; } div.sourceCode { margin: 1em 0; } pre.sourceCode { margin: 0; } @media screen { div.sourceCode { overflow: auto; } } @media print { pre > code.sourceCode { white-space: pre-wrap; } pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; } } pre.numberSource code { counter-reset: source-line 0; } pre.numberSource code > span { position: relative; left: -4em; counter-increment: source-line; } pre.numberSource code > span > a:first-child::before { content: counter(source-line); position: relative; left: -1em; text-align: right; vertical-align: baseline; border: none; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; padding: 0 4px; width: 4em; } pre.numberSource { margin-left: 3em; padding-left: 4px; } div.sourceCode { } @media screen { pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } } </style> <script src="site_libs/quarto-nav/quarto-nav.js"></script> <script src="site_libs/quarto-nav/headroom.min.js"></script> <script src="site_libs/clipboard/clipboard.min.js"></script> <script src="site_libs/quarto-search/autocomplete.umd.js"></script> <script src="site_libs/quarto-search/fuse.min.js"></script> <script src="site_libs/quarto-search/quarto-search.js"></script> <meta name="quarto:offset" content="./"> <script src="site_libs/quarto-html/quarto.js"></script> <script src="site_libs/quarto-html/popper.min.js"></script> <script src="site_libs/quarto-html/tippy.umd.min.js"></script> <script src="site_libs/quarto-html/anchor.min.js"></script> <link href="site_libs/quarto-html/tippy.css" rel="stylesheet"> <link href="site_libs/quarto-html/quarto-syntax-highlighting-2f5df379a58b258e96c21c0638c20c03.css" rel="stylesheet" id="quarto-text-highlighting-styles"> <script src="site_libs/bootstrap/bootstrap.min.js"></script> <link href="site_libs/bootstrap/bootstrap-icons.css" rel="stylesheet"> <link href="site_libs/bootstrap/bootstrap-ae44de7e3b26b230a7801128389852ee.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light"> <script id="quarto-search-options" type="application/json">{ "location": "navbar", "copy-button": false, "collapse-after": 3, "panel-placement": "end", "type": "overlay", "limit": 50, "keyboard-shortcut": [ "f", "/", "s" ], "show-item-context": false, "language": { "search-no-results-text": "No results", "search-matching-documents-text": "matching documents", "search-copy-link-title": "Copy link to search", "search-hide-matches-text": "Hide additional matches", "search-more-match-text": "more match in this document", "search-more-matches-text": "more matches in this document", "search-clear-button-title": "Clear", "search-text-placeholder": "", "search-detached-cancel-button-title": "Cancel", "search-submit-button-title": "Submit", "search-label": "Search" } }</script> <link rel="stylesheet" href="styles.css"> <meta property="og:title" content="tsai"> <meta property="og:description" content="Practical Deep Learning for Time Series / Sequential Data library based on fastai & Pytorch"> <meta property="og:site_name" content="tsai"> <meta name="twitter:title" content="tsai"> <meta name="twitter:description" content="Practical Deep Learning for Time Series / Sequential Data library based on fastai & Pytorch"> <meta name="twitter:card" content="summary"> </head> <body class="nav-sidebar floating nav-fixed"> <div id="quarto-search-results"></div> <header id="quarto-header" class="headroom fixed-top"> <nav class="navbar navbar-expand-lg " data-bs-theme="dark"> <div class="navbar-container container-fluid"> <div class="navbar-brand-container mx-auto"> <a class="navbar-brand" href="./index.html"> <span class="navbar-title">tsai</span> </a> </div> <div id="quarto-search" class="" title="Search"></div> <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" role="menu" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarCollapse"> <ul class="navbar-nav navbar-nav-scroll ms-auto"> <li class="nav-item compact"> <a class="nav-link" href="https://github.com/timeseriesAI/tsai"> <i class="bi bi-github" role="img"> </i> <span class="menu-text"></span></a> </li> </ul> </div> <!-- /navcollapse --> <div class="quarto-navbar-tools"> <a href="" class="quarto-reader-toggle quarto-navigation-tool px-1" onclick="window.quartoToggleReader(); return false;" title="Toggle reader mode"> <div class="quarto-reader-toggle-btn"> <i class="bi"></i> </div> </a> </div> </div> <!-- /container-fluid --> </nav> <nav class="quarto-secondary-nav"> <div class="container-fluid d-flex"> <button type="button" class="quarto-btn-toggle btn" data-bs-toggle="collapse" role="button" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> <i class="bi bi-layout-text-sidebar-reverse"></i> </button> <nav class="quarto-page-breadcrumbs" aria-label="breadcrumb"><ol class="breadcrumb"><li class="breadcrumb-item"><a href="./index.html">tsai</a></li></ol></nav> <a class="flex-grow-1" role="navigation" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item" aria-controls="quarto-sidebar" aria-expanded="false" aria-label="Toggle sidebar navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }"> </a> </div> </nav> </header> <!-- content --> <div id="quarto-content" class="quarto-container page-columns page-rows-contents page-layout-article page-navbar"> <!-- sidebar --> <nav id="quarto-sidebar" class="sidebar collapse collapse-horizontal quarto-sidebar-collapse-item sidebar-navigation floating overflow-auto"> <div class="sidebar-menu-container"> <ul class="list-unstyled mt-1"> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./index.html" class="sidebar-item-text sidebar-link active"> <span class="menu-text">tsai</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./tutorials.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Tutorial notebooks</span></a> </div> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="true"> <span class="menu-text">Data</span></a> <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-1" role="navigation" aria-expanded="true" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-1" class="collapse list-unstyled sidebar-section depth1 show"> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.core.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Data Core</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.external.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">External data</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.preparation.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Data preparation</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.validation.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Spliting data</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.preprocessing.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Data preprocessing</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.unwindowed.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Unwindowed datasets</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.transforms.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Time Series Data Augmentation</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.mixed_augmentation.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Label-mixing transforms</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.image.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Imaging Time Series</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.features.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Featurizing Time Series</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.tabular.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Time Series Tabular Data</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.mixed.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Mixed data</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./data.metadatasets.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Metadataset</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" role="navigation" aria-expanded="true"> <span class="menu-text">Models</span></a> <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-2" role="navigation" aria-expanded="true" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-2" class="collapse list-unstyled sidebar-section depth1 show"> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.layers.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Layers</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.utils.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Model utilities</span></a> </div> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" role="navigation" aria-expanded="false"> <span class="menu-text">MLPs</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-3" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-3" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.mlp.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MLP</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.gmlp.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">gMLP</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" role="navigation" aria-expanded="false"> <span class="menu-text">RNNs</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-4" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-4" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rnn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">RNNs</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rnnplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">RNNPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rnnattention.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">RNNAttention</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tssequencerplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TSSequencerPlus</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-5" role="navigation" aria-expanded="false"> <span class="menu-text">CNNs</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-5" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-5" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.fcn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">FCN</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.fcnplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">FCNPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.resnet.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">ResNet</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.resnetplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">ResNetPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.xresnet1d.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">XResNet1d</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.xresnet1dplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">XResNet1dPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rescnn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">ResCNN</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tcn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TCN</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.inceptiontime.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">InceptionTime</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.inceptiontimeplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">InceptionTimePlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.xceptiontime.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">XceptionTime</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.xceptiontimeplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">XceptionTimePlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.omniscalecnn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">OmniScaleCNN</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.xcm.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">XCM</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.xcmplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">XCMPlus</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-6" role="navigation" aria-expanded="false"> <span class="menu-text">Transformers</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-6" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-6" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.positional_encoders.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Positional encoders</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.transformermodel.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TransformerModel</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tst.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TST</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tstplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TSTPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tsperceiver.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TSPerceiver</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tsitplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TSiT</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.patchtst.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">PatchTST</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" role="navigation" aria-expanded="false"> <span class="menu-text">ROCKETs</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-7" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-7" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rocket.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">ROCKET</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rocket_pytorch.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">ROCKET Pytorch</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.minirocket.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MINIROCKET</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.minirocket_pytorch.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MINIROCKET Pytorch</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.minirocketplus_pytorch.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MINIROCKETPlus Pytorch</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.multirocketplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MultiRocketPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.hydraplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">HydraPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.hydramultirocketplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">HydraMultiRocketPlus</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-8" role="navigation" aria-expanded="false"> <span class="menu-text">Wavelet-based NNs</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-8" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-8" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.mwdn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">mWDN</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-9" role="navigation" aria-expanded="false"> <span class="menu-text">Hybrid models</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-9" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-9" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rnn_fcn.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">RNN_FCN</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.rnn_fcnplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">RNN_FCNPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.transformerrnnplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TransformerRNNPlus</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.convtranplus.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">ConvTranPlus</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-10" role="navigation" aria-expanded="false"> <span class="menu-text">Tabular models</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-10" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-10" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tabmodel.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TabModel</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tabtransformer.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TabTransformer</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.gatedtabtransformer.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">GatedTabTransformer</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.tabfusiontransformer.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TabFusionTransformer</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-11" role="navigation" aria-expanded="false"> <span class="menu-text">Miscellaneous</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-11" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-11" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.multiinputnet.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MultiInputNet</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.multimodal.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Multimodal</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.misc.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Miscellaneous</span></a> </div> </li> </ul> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-12" role="navigation" aria-expanded="true"> <span class="menu-text">Training</span></a> <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-12" role="navigation" aria-expanded="true" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-12" class="collapse list-unstyled sidebar-section depth1 show"> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./learner.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Learner</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./tslearner.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">TSLearner</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./optimizer.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Optimizers</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./losses.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Losses</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./metrics.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Metrics</span></a> </div> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-13" role="navigation" aria-expanded="false"> <span class="menu-text">Callbacks</span></a> <a class="sidebar-item-toggle text-start collapsed" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-13" role="navigation" aria-expanded="false" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-13" class="collapse list-unstyled sidebar-section depth2 "> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./callback.core.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Callback</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./callback.predictiondynamics.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">PredictionDynamics</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./callback.noisy_student.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Noisy student</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./callback.mvp.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">MVP (aka TSBERT)</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./callback.experimental.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Experimental Callbacks</span></a> </div> </li> </ul> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./calibration.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Calibration</span></a> </div> </li> </ul> </li> <li class="sidebar-item sidebar-item-section"> <div class="sidebar-item-container"> <a class="sidebar-item-text sidebar-link text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-14" role="navigation" aria-expanded="true"> <span class="menu-text">HPO & experiment tracking</span></a> <a class="sidebar-item-toggle text-start" data-bs-toggle="collapse" data-bs-target="#quarto-sidebar-section-14" role="navigation" aria-expanded="true" aria-label="Toggle section"> <i class="bi bi-chevron-right ms-2"></i> </a> </div> <ul id="quarto-sidebar-section-14" class="collapse list-unstyled sidebar-section depth1 show"> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./optuna.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Optuna</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./wandb.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Weights & Biases Sweeps</span></a> </div> </li> </ul> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./inference.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Inference</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./analysis.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Analysis</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./models.explainability.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Explainability</span></a> </div> </li> <li class="sidebar-item"> <div class="sidebar-item-container"> <a href="./utils.html" class="sidebar-item-text sidebar-link"> <span class="menu-text">Utilities</span></a> </div> </li> </ul> </div> </nav> <div id="quarto-sidebar-glass" class="quarto-sidebar-collapse-item" data-bs-toggle="collapse" data-bs-target=".quarto-sidebar-collapse-item"></div> <!-- margin-sidebar --> <div id="quarto-margin-sidebar" class="sidebar margin-sidebar"> <nav id="TOC" role="doc-toc" class="toc-active"> <h2 id="toc-title">On this page</h2> <ul> <li><a href="#description" id="toc-description" class="nav-link active" data-scroll-target="#description">Description</a></li> <li><a href="#whats-new" id="toc-whats-new" class="nav-link" data-scroll-target="#whats-new">What’s new:</a></li> <li><a href="#installation" id="toc-installation" class="nav-link" data-scroll-target="#installation">Installation</a> <ul> <li><a href="#pip-install" id="toc-pip-install" class="nav-link" data-scroll-target="#pip-install">Pip install</a></li> <li><a href="#conda-install" id="toc-conda-install" class="nav-link" data-scroll-target="#conda-install">Conda install</a></li> </ul></li> <li><a href="#documentation" id="toc-documentation" class="nav-link" data-scroll-target="#documentation">Documentation</a></li> <li><a href="#available-models" id="toc-available-models" class="nav-link" data-scroll-target="#available-models">Available models:</a></li> <li><a href="#how-to-start-using-tsai" id="toc-how-to-start-using-tsai" class="nav-link" data-scroll-target="#how-to-start-using-tsai">How to start using tsai?</a></li> <li><a href="#examples" id="toc-examples" class="nav-link" data-scroll-target="#examples">Examples</a> <ul> <li><a href="#binary-univariate-classification" id="toc-binary-univariate-classification" class="nav-link" data-scroll-target="#binary-univariate-classification">Binary, univariate classification</a></li> <li><a href="#multi-class-multivariate-classification" id="toc-multi-class-multivariate-classification" class="nav-link" data-scroll-target="#multi-class-multivariate-classification">Multi-class, multivariate classification</a></li> <li><a href="#multivariate-regression" id="toc-multivariate-regression" class="nav-link" data-scroll-target="#multivariate-regression">Multivariate Regression</a></li> <li><a href="#forecasting" id="toc-forecasting" class="nav-link" data-scroll-target="#forecasting">Forecasting</a> <ul class="collapse"> <li><a href="#single-step" id="toc-single-step" class="nav-link" data-scroll-target="#single-step">Single step</a></li> <li><a href="#multi-step" id="toc-multi-step" class="nav-link" data-scroll-target="#multi-step">Multi-step</a></li> </ul></li> </ul></li> <li><a href="#input-data-format" id="toc-input-data-format" class="nav-link" data-scroll-target="#input-data-format">Input data format</a></li> <li><a href="#how-to-contribute-to-tsai" id="toc-how-to-contribute-to-tsai" class="nav-link" data-scroll-target="#how-to-contribute-to-tsai">How to contribute to tsai?</a></li> <li><a href="#enterprise-support-and-consulting-services" id="toc-enterprise-support-and-consulting-services" class="nav-link" data-scroll-target="#enterprise-support-and-consulting-services">Enterprise support and consulting services:</a></li> <li><a href="#citing-tsai" id="toc-citing-tsai" class="nav-link" data-scroll-target="#citing-tsai">Citing tsai</a></li> </ul> <div class="toc-actions"><ul><li><a href="https://github.com/timeseriesAI/tsai/issues/new" class="toc-action"><i class="bi bi-github"></i>Report an issue</a></li></ul></div></nav> </div> <!-- main --> <main class="content" id="quarto-document-content"> <header id="title-block-header" class="quarto-title-block default"> <div class="quarto-title"> <h1 class="title">tsai</h1> </div> <div class="quarto-title-meta"> </div> </header> <!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! --> <div data-align="center"> <p><img src="https://github.com/timeseriesAI/tsai/blob/main/nbs/multimedia/tsai_logo.svg?raw=true" width="50%"></p> </div> <p><br> <br></p> <p><img src="https://github.com/timeseriesai/tsai/workflows/CI/badge.svg" class="img-fluid" alt="CI"> <a href="https://pypi.org/project/tsai/#description"><img src="https://img.shields.io/pypi/v/tsai?color=blue&label=pypi%20version.png" class="img-fluid" alt="PyPI"></a> <a href="https://anaconda.org/timeseriesai/tsai"><img src="https://img.shields.io/conda/vn/timeseriesai/tsai?color=brightgreen&label=conda%20version.png" class="img-fluid" alt="Conda (channel only)"></a> <a href="https://zenodo.org/badge/latestdoi/211822289"><img src="https://zenodo.org/badge/211822289.svg" class="img-fluid" alt="DOI"></a> <img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg" class="img-fluid" alt="PRs"></p> <section id="description" class="level2"> <h2 class="anchored" data-anchor-id="description">Description</h2> <blockquote class="blockquote"> <p>State-of-the-art Deep Learning library for Time Series and Sequences.</p> </blockquote> <p><code>tsai</code> is an open-source deep learning package built on top of Pytorch & fastai focused on state-of-the-art techniques for time series tasks like classification, regression, forecasting, imputation…</p> <p><code>tsai</code> is currently under active development by timeseriesAI.</p> </section> <section id="whats-new" class="level2"> <h2 class="anchored" data-anchor-id="whats-new">What’s new:</h2> <p>During the last few releases, here are some of the most significant additions to <code>tsai</code>:</p> <ul> <li><strong>New models</strong>: PatchTST (Accepted by ICLR 2023), RNN with Attention (RNNAttention, LSTMAttention, GRUAttention), TabFusionTransformer, …</li> <li><strong>New datasets</strong>: we have increased the number of datasets you can download using <code>tsai</code>: <ul> <li>128 univariate classification datasets</li> <li>30 multivariate classification datasets</li> <li>15 regression datasets</li> <li>62 forecasting datasets</li> <li>9 long term forecasting datasets</li> </ul></li> <li><strong>New tutorials</strong>: <a href="https://github.com/timeseriesAI/tsai/blob/main/tutorial_nbs/15_PatchTST_a_new_transformer_for_LTSF.ipynb">PatchTST</a>. Based on some of your requests, we are planning to release additional tutorials on data preparation and forecasting.</li> <li><strong>New functionality</strong>: sklearn-type pipeline transforms, walk-foward cross validation, reduced RAM requirements, and a lot of new functionality to perform more accurate time series forecasts.</li> <li>Pytorch 2.0 support.</li> </ul> </section> <section id="installation" class="level2"> <h2 class="anchored" data-anchor-id="installation">Installation</h2> <section id="pip-install" class="level3"> <h3 class="anchored" data-anchor-id="pip-install">Pip install</h3> <p>You can install the <strong>latest stable</strong> version from pip using:</p> <div class="sourceCode" id="cb1"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a>pip install tsai</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p>If you plan to develop tsai yourself, or want to be on the cutting edge, you can use an editable install. First install PyTorch, and then:</p> <div class="sourceCode" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>git clone https:<span class="op">//</span>github.com<span class="op">/</span>timeseriesAI<span class="op">/</span>tsai</span> <span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>pip install <span class="op">-</span>e <span class="st">"tsai[dev]"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p>Note: starting with tsai 0.3.0 tsai will only install hard dependencies. Other soft dependencies (which are only required for selected tasks) will not be installed by default (this is the recommended approach. If you require any of the dependencies that is not installed, tsai will ask you to install it when necessary). If you still want to install tsai with all its dependencies you can do it by running:</p> <div class="sourceCode" id="cb3"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>pip install tsai[extras]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> <section id="conda-install" class="level3"> <h3 class="anchored" data-anchor-id="conda-install">Conda install</h3> <p>You can also install tsai using conda (note that if you replace conda with mamba the install process will be much faster and more reliable):</p> <div class="sourceCode" id="cb4"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>conda install <span class="op">-</span>c timeseriesai tsai</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> </section> <section id="documentation" class="level2"> <h2 class="anchored" data-anchor-id="documentation">Documentation</h2> <p>Here’s the link to the <a href="https://timeseriesai.github.io/tsai/">documentation</a>.</p> </section> <section id="available-models" class="level2"> <h2 class="anchored" data-anchor-id="available-models">Available models:</h2> <p>Here’s a list with some of the state-of-the-art models available in <code>tsai</code>:</p> <ul> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/RNN.py">LSTM</a> (Hochreiter, 1997) (<a href="https://ieeexplore.ieee.org/abstract/document/6795963/">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/RNN.py">GRU</a> (Cho, 2014) (<a href="https://arxiv.org/abs/1412.3555">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/MLP.py">MLP</a> - Multilayer Perceptron (Wang, 2016) (<a href="https://arxiv.org/abs/1611.06455">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/FCN.py">FCN</a> - Fully Convolutional Network (Wang, 2016) (<a href="https://arxiv.org/abs/1611.06455">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/ResNet.py">ResNet</a> - Residual Network (Wang, 2016) (<a href="https://arxiv.org/abs/1611.06455">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/RNN_FCN.py">LSTM-FCN</a> (Karim, 2017) (<a href="https://arxiv.org/abs/1709.05206">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/RNN_FCN.py">GRU-FCN</a> (Elsayed, 2018) (<a href="https://arxiv.org/abs/1812.07683">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/mWDN.py">mWDN</a> - Multilevel wavelet decomposition network (Wang, 2018) (<a href="https://dl.acm.org/doi/abs/10.1145/3219819.3220060">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TCN.py">TCN</a> - Temporal Convolutional Network (Bai, 2018) (<a href="https://arxiv.org/abs/1803.01271">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/RNN_FCN.py">MLSTM-FCN</a> - Multivariate LSTM-FCN (Karim, 2019) (<a href="https://www.sciencedirect.com/science/article/abs/pii/S0893608019301200">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/InceptionTime.py">InceptionTime</a> (Fawaz, 2019) (<a href="https://arxiv.org/abs/1909.04939">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/ROCKET.py">Rocket</a> (Dempster, 2019) (<a href="https://arxiv.org/abs/1910.13051">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/XceptionTime.py">XceptionTime</a> (Rahimian, 2019) (<a href="https://arxiv.org/abs/1911.03803">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/ResCNN.py">ResCNN</a> - 1D-ResCNN (Zou , 2019) (<a href="https://www.sciencedirect.com/science/article/pii/S0925231219311506">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TabModel.py">TabModel</a> - modified from fastai’s <a href="https://docs.fast.ai/tabular.model.html#TabularModel">TabularModel</a></li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/OmniScaleCNN.py">OmniScale</a> - Omni-Scale 1D-CNN (Tang, 2020) (<a href="https://arxiv.org/abs/2002.10061">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TST.py">TST</a> - Time Series Transformer (Zerveas, 2020) (<a href="https://dl.acm.org/doi/abs/10.1145/3447548.3467401">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TabTransformer.py">TabTransformer</a> (Huang, 2020) (<a href="https://arxiv.org/pdf/2012.06678">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TSiTPlus.py">TSiT</a> Adapted from ViT (Dosovitskiy, 2020) (<a href="https://arxiv.org/abs/2010.11929">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/MINIROCKET.py">MiniRocket</a> (Dempster, 2021) (<a href="https://arxiv.org/abs/2102.00457">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/XCM.py">XCM</a> - An Explainable Convolutional Neural Network (Fauvel, 2021) (<a href="https://hal.inria.fr/hal-03469487/document">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/gMLP.py">gMLP</a> - Gated Multilayer Perceptron (Liu, 2021) (<a href="https://arxiv.org/abs/2105.08050">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TSPerceiver.py">TSPerceiver</a> - Adapted from Perceiver IO (Jaegle, 2021) (<a href="https://arxiv.org/abs/2107.14795">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/GatedTabTransformer.py">GatedTabTransformer</a> (Cholakov, 2022) (<a href="https://arxiv.org/abs/2201.00199">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/TSSequencerPlus.py">TSSequencerPlus</a> - Adapted from Sequencer (Tatsunami, 2022) (<a href="https://arxiv.org/abs/2205.01972">paper</a>)</li> <li><a href="https://github.com/timeseriesAI/tsai/blob/main/tsai/models/PatchTST.py">PatchTST</a> - (Nie, 2022) (<a href="https://arxiv.org/abs/2211.14730">paper</a>)</li> </ul> <p>plus other custom models like: TransformerModel, LSTMAttention, GRUAttention, …</p> </section> <section id="how-to-start-using-tsai" class="level2"> <h2 class="anchored" data-anchor-id="how-to-start-using-tsai">How to start using tsai?</h2> <p>To get to know the tsai package, we’d suggest you start with this notebook in Google Colab: <strong><a href="https://colab.research.google.com/github/timeseriesAI/tsai/blob/master/tutorial_nbs/01_Intro_to_Time_Series_Classification.ipynb">01_Intro_to_Time_Series_Classification</a></strong> It provides an overview of a time series classification task.</p> <p>We have also develop many other <a href="https://github.com/timeseriesAI/tsai/tree/main/tutorial_nbs">tutorial notebooks</a>.</p> <p>To use tsai in your own notebooks, the only thing you need to do after you have installed the package is to run this:</p> <div class="sourceCode" id="cb5"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.<span class="bu">all</span> <span class="im">import</span> <span class="op">*</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> <section id="examples" class="level2"> <h2 class="anchored" data-anchor-id="examples">Examples</h2> <p>These are just a few examples of how you can use <code>tsai</code>:</p> <section id="binary-univariate-classification" class="level3"> <h3 class="anchored" data-anchor-id="binary-univariate-classification">Binary, univariate classification</h3> <p><strong>Training:</strong></p> <div class="sourceCode" id="cb6"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.basics <span class="im">import</span> <span class="op">*</span></span> <span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>X, y, splits <span class="op">=</span> get_classification_data(<span class="st">'ECG200'</span>, split_data<span class="op">=</span><span class="va">False</span>)</span> <span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>tfms <span class="op">=</span> [<span class="va">None</span>, TSClassification()]</span> <span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a>batch_tfms <span class="op">=</span> TSStandardize()</span> <span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a>clf <span class="op">=</span> TSClassifier(X, y, splits<span class="op">=</span>splits, path<span class="op">=</span><span class="st">'models'</span>, arch<span class="op">=</span><span class="st">"InceptionTimePlus"</span>, tfms<span class="op">=</span>tfms, batch_tfms<span class="op">=</span>batch_tfms, metrics<span class="op">=</span>accuracy, cbs<span class="op">=</span>ShowGraph())</span> <span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>clf.fit_one_cycle(<span class="dv">100</span>, <span class="fl">3e-4</span>)</span> <span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a>clf.export(<span class="st">"clf.pkl"</span>) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Inference:</strong></p> <div class="sourceCode" id="cb7"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.inference <span class="im">import</span> load_learner</span> <span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a>clf <span class="op">=</span> load_learner(<span class="st">"models/clf.pkl"</span>)</span> <span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>probas, target, preds <span class="op">=</span> clf.get_X_preds(X[splits[<span class="dv">1</span>]], y[splits[<span class="dv">1</span>]])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> <section id="multi-class-multivariate-classification" class="level3"> <h3 class="anchored" data-anchor-id="multi-class-multivariate-classification">Multi-class, multivariate classification</h3> <p><strong>Training:</strong></p> <div class="sourceCode" id="cb8"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.basics <span class="im">import</span> <span class="op">*</span></span> <span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a>X, y, splits <span class="op">=</span> get_classification_data(<span class="st">'LSST'</span>, split_data<span class="op">=</span><span class="va">False</span>)</span> <span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a>tfms <span class="op">=</span> [<span class="va">None</span>, TSClassification()]</span> <span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a>batch_tfms <span class="op">=</span> TSStandardize(by_sample<span class="op">=</span><span class="va">True</span>)</span> <span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a>mv_clf <span class="op">=</span> TSClassifier(X, y, splits<span class="op">=</span>splits, path<span class="op">=</span><span class="st">'models'</span>, arch<span class="op">=</span><span class="st">"InceptionTimePlus"</span>, tfms<span class="op">=</span>tfms, batch_tfms<span class="op">=</span>batch_tfms, metrics<span class="op">=</span>accuracy, cbs<span class="op">=</span>ShowGraph())</span> <span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a>mv_clf.fit_one_cycle(<span class="dv">10</span>, <span class="fl">1e-2</span>)</span> <span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a>mv_clf.export(<span class="st">"mv_clf.pkl"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Inference:</strong></p> <div class="sourceCode" id="cb9"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.inference <span class="im">import</span> load_learner</span> <span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a>mv_clf <span class="op">=</span> load_learner(<span class="st">"models/mv_clf.pkl"</span>)</span> <span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a>probas, target, preds <span class="op">=</span> mv_clf.get_X_preds(X[splits[<span class="dv">1</span>]], y[splits[<span class="dv">1</span>]])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> <section id="multivariate-regression" class="level3"> <h3 class="anchored" data-anchor-id="multivariate-regression">Multivariate Regression</h3> <p><strong>Training:</strong></p> <div class="sourceCode" id="cb10"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.basics <span class="im">import</span> <span class="op">*</span></span> <span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>X, y, splits <span class="op">=</span> get_regression_data(<span class="st">'AppliancesEnergy'</span>, split_data<span class="op">=</span><span class="va">False</span>)</span> <span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a>tfms <span class="op">=</span> [<span class="va">None</span>, TSRegression()]</span> <span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a>batch_tfms <span class="op">=</span> TSStandardize(by_sample<span class="op">=</span><span class="va">True</span>)</span> <span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a>reg <span class="op">=</span> TSRegressor(X, y, splits<span class="op">=</span>splits, path<span class="op">=</span><span class="st">'models'</span>, arch<span class="op">=</span><span class="st">"TSTPlus"</span>, tfms<span class="op">=</span>tfms, batch_tfms<span class="op">=</span>batch_tfms, metrics<span class="op">=</span>rmse, cbs<span class="op">=</span>ShowGraph(), verbose<span class="op">=</span><span class="va">True</span>)</span> <span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a>reg.fit_one_cycle(<span class="dv">100</span>, <span class="fl">3e-4</span>)</span> <span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a>reg.export(<span class="st">"reg.pkl"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Inference:</strong></p> <div class="sourceCode" id="cb11"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.inference <span class="im">import</span> load_learner</span> <span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>reg <span class="op">=</span> load_learner(<span class="st">"models/reg.pkl"</span>)</span> <span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>raw_preds, target, preds <span class="op">=</span> reg.get_X_preds(X[splits[<span class="dv">1</span>]], y[splits[<span class="dv">1</span>]])</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p>The ROCKETs (RocketClassifier, RocketRegressor, MiniRocketClassifier, MiniRocketRegressor, MiniRocketVotingClassifier or MiniRocketVotingRegressor) are somewhat different models. They are not actually deep learning models (although they use convolutions) and are used in a different way.</p> <p>⚠️ You’ll also need to install sktime to be able to use them. You can install it separately:</p> <div class="sourceCode" id="cb12"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>pip install sktime</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p>or use:</p> <div class="sourceCode" id="cb13"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>pip install tsai[extras]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Training:</strong></p> <div class="sourceCode" id="cb14"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> sklearn.metrics <span class="im">import</span> mean_squared_error, make_scorer</span> <span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.data.external <span class="im">import</span> get_Monash_regression_data</span> <span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.models.MINIROCKET <span class="im">import</span> MiniRocketRegressor</span> <span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a></span> <span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a>X_train, y_train, <span class="op">*</span>_ <span class="op">=</span> get_Monash_regression_data(<span class="st">'AppliancesEnergy'</span>)</span> <span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a>rmse_scorer <span class="op">=</span> make_scorer(mean_squared_error, greater_is_better<span class="op">=</span><span class="va">False</span>)</span> <span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a>reg <span class="op">=</span> MiniRocketRegressor(scoring<span class="op">=</span>rmse_scorer)</span> <span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a>reg.fit(X_train, y_train)</span> <span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a>reg.save(<span class="st">'MiniRocketRegressor'</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Inference:</strong></p> <div class="sourceCode" id="cb15"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> sklearn.metrics <span class="im">import</span> mean_squared_error</span> <span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.data.external <span class="im">import</span> get_Monash_regression_data</span> <span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.models.MINIROCKET <span class="im">import</span> load_minirocket</span> <span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a></span> <span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="op">*</span>_, X_test, y_test <span class="op">=</span> get_Monash_regression_data(<span class="st">'AppliancesEnergy'</span>)</span> <span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a>reg <span class="op">=</span> load_minirocket(<span class="st">'MiniRocketRegressor'</span>)</span> <span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a>y_pred <span class="op">=</span> reg.predict(X_test)</span> <span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a>mean_squared_error(y_test, y_pred, squared<span class="op">=</span><span class="va">False</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> <section id="forecasting" class="level3"> <h3 class="anchored" data-anchor-id="forecasting">Forecasting</h3> <p>You can use tsai for forecast in the following scenarios:</p> <ul> <li>univariate or multivariate time series input</li> <li>univariate or multivariate time series output</li> <li>single or multi-step ahead</li> </ul> <p>You’ll need to: * prepare X (time series input) and the target y (see <a href="https://timeseriesai.github.io/tsai/data.preparation.html">documentation</a>) * select PatchTST or one of tsai’s models ending in Plus (TSTPlus, InceptionTimePlus, TSiTPlus, etc). The model will auto-configure a head to yield an output with the same shape as the target input y.</p> <section id="single-step" class="level4"> <h4 class="anchored" data-anchor-id="single-step">Single step</h4> <p><strong>Training:</strong></p> <div class="sourceCode" id="cb16"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.basics <span class="im">import</span> <span class="op">*</span></span> <span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a>ts <span class="op">=</span> get_forecasting_time_series(<span class="st">"Sunspots"</span>).values</span> <span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a>X, y <span class="op">=</span> SlidingWindow(<span class="dv">60</span>, horizon<span class="op">=</span><span class="dv">1</span>)(ts)</span> <span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a>splits <span class="op">=</span> TimeSplitter(<span class="dv">235</span>)(y) </span> <span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a>tfms <span class="op">=</span> [<span class="va">None</span>, TSForecasting()]</span> <span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a>batch_tfms <span class="op">=</span> TSStandardize()</span> <span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a>fcst <span class="op">=</span> TSForecaster(X, y, splits<span class="op">=</span>splits, path<span class="op">=</span><span class="st">'models'</span>, tfms<span class="op">=</span>tfms, batch_tfms<span class="op">=</span>batch_tfms, bs<span class="op">=</span><span class="dv">512</span>, arch<span class="op">=</span><span class="st">"TSTPlus"</span>, metrics<span class="op">=</span>mae, cbs<span class="op">=</span>ShowGraph())</span> <span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a>fcst.fit_one_cycle(<span class="dv">50</span>, <span class="fl">1e-3</span>)</span> <span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a>fcst.export(<span class="st">"fcst.pkl"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Inference:</strong></p> <div class="sourceCode" id="cb17"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.inference <span class="im">import</span> load_learner</span> <span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>fcst <span class="op">=</span> load_learner(<span class="st">"models/fcst.pkl"</span>, cpu<span class="op">=</span><span class="va">False</span>)</span> <span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a>raw_preds, target, preds <span class="op">=</span> fcst.get_X_preds(X[splits[<span class="dv">1</span>]], y[splits[<span class="dv">1</span>]])</span> <span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a>raw_preds.shape</span> <span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a><span class="co"># torch.Size([235, 1])</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> <section id="multi-step" class="level4"> <h4 class="anchored" data-anchor-id="multi-step">Multi-step</h4> <p>This example show how to build a 3-step ahead univariate forecast.</p> <p><strong>Training:</strong></p> <div class="sourceCode" id="cb18"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.basics <span class="im">import</span> <span class="op">*</span></span> <span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a></span> <span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>ts <span class="op">=</span> get_forecasting_time_series(<span class="st">"Sunspots"</span>).values</span> <span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a>X, y <span class="op">=</span> SlidingWindow(<span class="dv">60</span>, horizon<span class="op">=</span><span class="dv">3</span>)(ts)</span> <span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a>splits <span class="op">=</span> TimeSplitter(<span class="dv">235</span>, fcst_horizon<span class="op">=</span><span class="dv">3</span>)(y) </span> <span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a>tfms <span class="op">=</span> [<span class="va">None</span>, TSForecasting()]</span> <span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a>batch_tfms <span class="op">=</span> TSStandardize()</span> <span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a>fcst <span class="op">=</span> TSForecaster(X, y, splits<span class="op">=</span>splits, path<span class="op">=</span><span class="st">'models'</span>, tfms<span class="op">=</span>tfms, batch_tfms<span class="op">=</span>batch_tfms, bs<span class="op">=</span><span class="dv">512</span>, arch<span class="op">=</span><span class="st">"TSTPlus"</span>, metrics<span class="op">=</span>mae, cbs<span class="op">=</span>ShowGraph())</span> <span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a>fcst.fit_one_cycle(<span class="dv">50</span>, <span class="fl">1e-3</span>)</span> <span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a>fcst.export(<span class="st">"fcst.pkl"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> <p><strong>Inference:</strong></p> <div class="sourceCode" id="cb19"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="im">from</span> tsai.inference <span class="im">import</span> load_learner</span> <span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>fcst <span class="op">=</span> load_learner(<span class="st">"models/fcst.pkl"</span>, cpu<span class="op">=</span><span class="va">False</span>)</span> <span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a>raw_preds, target, preds <span class="op">=</span> fcst.get_X_preds(X[splits[<span class="dv">1</span>]], y[splits[<span class="dv">1</span>]])</span> <span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a>raw_preds.shape</span> <span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a><span class="co"># torch.Size([235, 3])</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div> </section> </section> </section> <section id="input-data-format" class="level2"> <h2 class="anchored" data-anchor-id="input-data-format">Input data format</h2> <p>The input format for all time series models and image models in tsai is the same. An np.ndarray (or array-like object like zarr, etc) with 3 dimensions:</p> <p><strong>[# samples x # variables x sequence length]</strong></p> <p>The input format for tabular models in tsai (like TabModel, TabTransformer and TabFusionTransformer) is a pandas dataframe. See <a href="https://timeseriesai.github.io/tsai/models.TabModel.html">example</a>.</p> </section> <section id="how-to-contribute-to-tsai" class="level2"> <h2 class="anchored" data-anchor-id="how-to-contribute-to-tsai">How to contribute to tsai?</h2> <p>We welcome contributions of all kinds. Development of enhancements, bug fixes, documentation, tutorial notebooks, …</p> <p>We have created a guide to help you start contributing to tsai. You can read it <a href="https://github.com/timeseriesAI/tsai/blob/main/CONTRIBUTING.md">here</a>.</p> </section> <section id="enterprise-support-and-consulting-services" class="level2"> <h2 class="anchored" data-anchor-id="enterprise-support-and-consulting-services">Enterprise support and consulting services:</h2> <p>Want to make the most out of timeseriesAI/tsai in a professional setting? Let us help. Send us an email to learn more: info@timeseriesai.co</p> </section> <section id="citing-tsai" class="level2"> <h2 class="anchored" data-anchor-id="citing-tsai">Citing tsai</h2> <p>If you use tsai in your research please use the following BibTeX entry:</p> <pre class="text"><code>@Misc{tsai, author = {Ignacio Oguiza}, title = {tsai - A state-of-the-art deep learning library for time series and sequential data}, howpublished = {Github}, year = {2023}, url = {https://github.com/timeseriesAI/tsai} }</code></pre> </section> </main> <!-- /main --> <script id="quarto-html-after-body" type="application/javascript"> window.document.addEventListener("DOMContentLoaded", function (event) { const toggleBodyColorMode = (bsSheetEl) => { const mode = bsSheetEl.getAttribute("data-mode"); const bodyEl = window.document.querySelector("body"); if (mode === "dark") { bodyEl.classList.add("quarto-dark"); bodyEl.classList.remove("quarto-light"); } else { bodyEl.classList.add("quarto-light"); bodyEl.classList.remove("quarto-dark"); } } const toggleBodyColorPrimary = () => { const bsSheetEl = window.document.querySelector("link#quarto-bootstrap"); if (bsSheetEl) { toggleBodyColorMode(bsSheetEl); } } toggleBodyColorPrimary(); const icon = ""; const anchorJS = new window.AnchorJS(); anchorJS.options = { placement: 'right', icon: icon }; anchorJS.add('.anchored'); const isCodeAnnotation = (el) => { for (const clz of el.classList) { if (clz.startsWith('code-annotation-')) { return true; } } return false; } const onCopySuccess = function(e) { // button target const button = e.trigger; // don't keep focus button.blur(); // flash "checked" button.classList.add('code-copy-button-checked'); var currentTitle = button.getAttribute("title"); button.setAttribute("title", "Copied!"); let tooltip; if (window.bootstrap) { button.setAttribute("data-bs-toggle", "tooltip"); button.setAttribute("data-bs-placement", "left"); button.setAttribute("data-bs-title", "Copied!"); tooltip = new bootstrap.Tooltip(button, { trigger: "manual", customClass: "code-copy-button-tooltip", offset: [0, -8]}); tooltip.show(); } setTimeout(function() { if (tooltip) { tooltip.hide(); button.removeAttribute("data-bs-title"); button.removeAttribute("data-bs-toggle"); button.removeAttribute("data-bs-placement"); } button.setAttribute("title", currentTitle); button.classList.remove('code-copy-button-checked'); }, 1000); // clear code selection e.clearSelection(); } const getTextToCopy = function(trigger) { const codeEl = trigger.previousElementSibling.cloneNode(true); for (const childEl of codeEl.children) { if (isCodeAnnotation(childEl)) { childEl.remove(); } } return codeEl.innerText; } const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', { text: getTextToCopy }); clipboard.on('success', onCopySuccess); if (window.document.getElementById('quarto-embedded-source-code-modal')) { const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', { text: getTextToCopy, container: window.document.getElementById('quarto-embedded-source-code-modal') }); clipboardModal.on('success', onCopySuccess); } var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//); var mailtoRegex = new RegExp(/^mailto:/); var filterRegex = new RegExp("https:\/\/timeseriesAI\.github\.io\/tsai\/"); var isInternal = (href) => { return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href); } // Inspect non-navigation links and adorn them if external var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)'); for (var i=0; i<links.length; i++) { const link = links[i]; if (!isInternal(link.href)) { // undo the damage that might have been done by quarto-nav.js in the case of // links that we want to consider external if (link.dataset.originalHref !== undefined) { link.href = link.dataset.originalHref; } } } function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) { const config = { allowHTML: true, maxWidth: 500, delay: 100, arrow: false, appendTo: function(el) { return el.parentElement; }, interactive: true, interactiveBorder: 10, theme: 'quarto', placement: 'bottom-start', }; if (contentFn) { config.content = contentFn; } if (onTriggerFn) { config.onTrigger = onTriggerFn; } if (onUntriggerFn) { config.onUntrigger = onUntriggerFn; } window.tippy(el, config); } const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]'); for (var i=0; i<noterefs.length; i++) { const ref = noterefs[i]; tippyHover(ref, function() { // use id or data attribute instead here let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href'); try { href = new URL(href).hash; } catch {} const id = href.replace(/^#\/?/, ""); const note = window.document.getElementById(id); if (note) { return note.innerHTML; } else { return ""; } }); } const xrefs = window.document.querySelectorAll('a.quarto-xref'); const processXRef = (id, note) => { // Strip column container classes const stripColumnClz = (el) => { el.classList.remove("page-full", "page-columns"); if (el.children) { for (const child of el.children) { stripColumnClz(child); } } } stripColumnClz(note) if (id === null || id.startsWith('sec-')) { // Special case sections, only their first couple elements const container = document.createElement("div"); if (note.children && note.children.length > 2) { container.appendChild(note.children[0].cloneNode(true)); for (let i = 1; i < note.children.length; i++) { const child = note.children[i]; if (child.tagName === "P" && child.innerText === "") { continue; } else { container.appendChild(child.cloneNode(true)); break; } } if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(container); } return container.innerHTML } else { if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(note); } return note.innerHTML; } } else { // Remove any anchor links if they are present const anchorLink = note.querySelector('a.anchorjs-link'); if (anchorLink) { anchorLink.remove(); } if (window.Quarto?.typesetMath) { window.Quarto.typesetMath(note); } if (note.classList.contains("callout")) { return note.outerHTML; } else { return note.innerHTML; } } } for (var i=0; i<xrefs.length; i++) { const xref = xrefs[i]; tippyHover(xref, undefined, function(instance) { instance.disable(); let url = xref.getAttribute('href'); let hash = undefined; if (url.startsWith('#')) { hash = url; } else { try { hash = new URL(url).hash; } catch {} } if (hash) { const id = hash.replace(/^#\/?/, ""); const note = window.document.getElementById(id); if (note !== null) { try { const html = processXRef(id, note.cloneNode(true)); instance.setContent(html); } finally { instance.enable(); instance.show(); } } else { // See if we can fetch this fetch(url.split('#')[0]) .then(res => res.text()) .then(html => { const parser = new DOMParser(); const htmlDoc = parser.parseFromString(html, "text/html"); const note = htmlDoc.getElementById(id); if (note !== null) { const html = processXRef(id, note); instance.setContent(html); } }).finally(() => { instance.enable(); instance.show(); }); } } else { // See if we can fetch a full url (with no hash to target) // This is a special case and we should probably do some content thinning / targeting fetch(url) .then(res => res.text()) .then(html => { const parser = new DOMParser(); const htmlDoc = parser.parseFromString(html, "text/html"); const note = htmlDoc.querySelector('main.content'); if (note !== null) { // This should only happen for chapter cross references // (since there is no id in the URL) // remove the first header if (note.children.length > 0 && note.children[0].tagName === "HEADER") { note.children[0].remove(); } const html = processXRef(null, note); instance.setContent(html); } }).finally(() => { instance.enable(); instance.show(); }); } }, function(instance) { }); } let selectedAnnoteEl; const selectorForAnnotation = ( cell, annotation) => { let cellAttr = 'data-code-cell="' + cell + '"'; let lineAttr = 'data-code-annotation="' + annotation + '"'; const selector = 'span[' + cellAttr + '][' + lineAttr + ']'; return selector; } const selectCodeLines = (annoteEl) => { const doc = window.document; const targetCell = annoteEl.getAttribute("data-target-cell"); const targetAnnotation = annoteEl.getAttribute("data-target-annotation"); const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation)); const lines = annoteSpan.getAttribute("data-code-lines").split(","); const lineIds = lines.map((line) => { return targetCell + "-" + line; }) let top = null; let height = null; let parent = null; if (lineIds.length > 0) { //compute the position of the single el (top and bottom and make a div) const el = window.document.getElementById(lineIds[0]); top = el.offsetTop; height = el.offsetHeight; parent = el.parentElement.parentElement; if (lineIds.length > 1) { const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]); const bottom = lastEl.offsetTop + lastEl.offsetHeight; height = bottom - top; } if (top !== null && height !== null && parent !== null) { // cook up a div (if necessary) and position it let div = window.document.getElementById("code-annotation-line-highlight"); if (div === null) { div = window.document.createElement("div"); div.setAttribute("id", "code-annotation-line-highlight"); div.style.position = 'absolute'; parent.appendChild(div); } div.style.top = top - 2 + "px"; div.style.height = height + 4 + "px"; div.style.left = 0; let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter"); if (gutterDiv === null) { gutterDiv = window.document.createElement("div"); gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter"); gutterDiv.style.position = 'absolute'; const codeCell = window.document.getElementById(targetCell); const gutter = codeCell.querySelector('.code-annotation-gutter'); gutter.appendChild(gutterDiv); } gutterDiv.style.top = top - 2 + "px"; gutterDiv.style.height = height + 4 + "px"; } selectedAnnoteEl = annoteEl; } }; const unselectCodeLines = () => { const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"]; elementsIds.forEach((elId) => { const div = window.document.getElementById(elId); if (div) { div.remove(); } }); selectedAnnoteEl = undefined; }; // Handle positioning of the toggle window.addEventListener( "resize", throttle(() => { elRect = undefined; if (selectedAnnoteEl) { selectCodeLines(selectedAnnoteEl); } }, 10) ); function throttle(fn, ms) { let throttle = false; let timer; return (...args) => { if(!throttle) { // first call gets through fn.apply(this, args); throttle = true; } else { // all the others get throttled if(timer) clearTimeout(timer); // cancel #2 timer = setTimeout(() => { fn.apply(this, args); timer = throttle = false; }, ms); } }; } // Attach click handler to the DT const annoteDls = window.document.querySelectorAll('dt[data-target-cell]'); for (const annoteDlNode of annoteDls) { annoteDlNode.addEventListener('click', (event) => { const clickedEl = event.target; if (clickedEl !== selectedAnnoteEl) { unselectCodeLines(); const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active'); if (activeEl) { activeEl.classList.remove('code-annotation-active'); } selectCodeLines(clickedEl); clickedEl.classList.add('code-annotation-active'); } else { // Unselect the line unselectCodeLines(); clickedEl.classList.remove('code-annotation-active'); } }); } const findCites = (el) => { const parentEl = el.parentElement; if (parentEl) { const cites = parentEl.dataset.cites; if (cites) { return { el, cites: cites.split(' ') }; } else { return findCites(el.parentElement) } } else { return undefined; } }; var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]'); for (var i=0; i<bibliorefs.length; i++) { const ref = bibliorefs[i]; const citeInfo = findCites(ref); if (citeInfo) { tippyHover(citeInfo.el, function() { var popup = window.document.createElement('div'); citeInfo.cites.forEach(function(cite) { var citeDiv = window.document.createElement('div'); citeDiv.classList.add('hanging-indent'); citeDiv.classList.add('csl-entry'); var biblioDiv = window.document.getElementById('ref-' + cite); if (biblioDiv) { citeDiv.innerHTML = biblioDiv.innerHTML; } popup.appendChild(citeDiv); }); return popup.innerHTML; }); } } }); </script> </div> <!-- /content --> <footer class="footer"><div class="nav-footer"><div class="nav-footer-center"><div class="toc-actions d-sm-block d-md-none"><ul><li><a href="https://github.com/timeseriesAI/tsai/issues/new" class="toc-action"><i class="bi bi-github"></i>Report an issue</a></li></ul></div></div></div></footer></body></html>