Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish to PyPI

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- run: uv build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/timee-ts
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ cython_debug/
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/
# Temporary file for partial code execution
Expand Down
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-added-large-files
- id: check-merge-conflict

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.4
hooks:
- id: ruff
args: [--fix]
- id: ruff-format
62 changes: 61 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
# timee
# TIMEE: Time Series Classification via In-Context Learning

TIMEE is a pretrained transformer for time series classification. It classifies test
series in a single forward pass given labeled training examples — no per-dataset
training or fine-tuning required.

**Paper:** *TIMEE: End-to-end Time Series Classification via In-Context Learning*

## Installation

```bash
pip install timee-ts
```

Requirements: Python ≥ 3.10, PyTorch ≥ 2.0.

## Quickstart

```python
from timee import TimeeClassifier
import numpy as np

clf = TimeeClassifier.from_pretrained() # downloads from HuggingFace on first use

# X: (n_samples, n_channels, seq_len) float32
X_train = np.random.randn(20, 1, 256).astype(np.float32)
y_train = np.array([0, 1] * 10)
X_test = np.random.randn(5, 1, 256).astype(np.float32)

predictions, probabilities = clf.predict(X_train, y_train, X_test)
```

Labels can be any type (`int`, `str`, etc.). Datasets with more than 10 classes are
handled automatically via one-vs-rest.

## API

### `TimeeClassifier.from_pretrained(path, device=None, use_ensemble=True)`

Loads a checkpoint from a directory containing `model.safetensors`.

| Parameter | Default | Description |
|-----------|---------|-------------|
| `path` | `"liamsbhoo/timee"` | Local directory or HuggingFace Hub repo ID. |
| `device` | auto | `"cuda"`, `"cpu"`, or `torch.device`. Defaults to CUDA > MPS > CPU. |
| `use_ensemble` | `True` | 4-member preprocessing ensemble (interpolate×{256,512} × {raw, diff}). Set `False` for faster single-pass inference. |

### `clf.predict(X_train, y_train, X_test)`

Returns `(predictions, probabilities)`:
- `predictions`: `(n_test,)`, same type as `y_train`
- `probabilities`: `(n_test, n_classes)`, rows sum to 1

## Citation

```bibtex
@inproceedings{timee2026,
title = {TIMEE: End-to-end Time Series Classification via In-Context Learning},
year = {2026},
}
```
460 changes: 460 additions & 0 deletions example.ipynb

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "timee-ts"
version = "0.1.0"
description = "End-to-end time series classification via in-context learning"
readme = "README.md"
requires-python = ">=3.10"
license = { file = "LICENSE" }
authors = [
{ name = "Liam Shi Bin Hoo", email = "hoos@tf.uni-freiburg.de" },
{ name = "Jaris Küken", email = "kuekenj@informatik.uni-freiburg.de" },
]
keywords = ["time-series", "classification", "in-context learning"]
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
"torch>=2.0",
"numpy>=1.24",
"scipy>=1.10",
"einops>=0.7",
"safetensors>=0.4",
"scikit-learn>=1.3",
"huggingface_hub>=0.20",
]

[project.optional-dependencies]
dev = [
"pytest",
"ruff",
"pre-commit",
"aeon",
"matplotlib",
]

[tool.hatch.build.targets.wheel]
packages = ["src/timee"]

[tool.ruff]
line-length = 100

[tool.ruff.lint]
select = ["E", "F", "I"]

[tool.ruff.lint.per-file-ignores]
"*.ipynb" = ["E402"]
5 changes: 5 additions & 0 deletions src/timee/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""TIMEE: End-to-end time series classification via in-context learning."""

from timee.classifier import TimeeClassifier

__all__ = ["TimeeClassifier"]
Loading