> ## Documentation Index
> Fetch the complete documentation index at: https://khaos-ml.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Telemetry

> Sensor streams: maintenance, ECG screening, regime alerts.

## Predictive maintenance on a vibration sensor

**Problem:** alert when a motor starts to look unhealthy. **Uses:** Khaos, NumPy and
SciPy.

```python theme={null}
import khaos
import numpy as np
from scipy.signal import butter, sosfilt

detector = khaos.load("tele_sensor_vibration")
sos = butter(4, [10, 2000], btype="band", fs=10_000, output="sos")

WINDOW = 4096
buffer = np.zeros(0)
for chunk in sensor.stream():          # 1-D arrays of samples
    buffer = np.concatenate([buffer, sosfilt(sos, chunk)])
    while len(buffer) >= WINDOW:
        window, buffer = buffer[:WINDOW], buffer[WINDOW:]
        score = detector(window).anomaly_score
        if score > 0.8:
            print("inspect motor, score", round(score, 2))
# inspect motor, score 0.86
```

## Screen ECG recordings

**Problem:** rank recordings by how unusual they look so a clinician reviews the
worst first. **Uses:** Khaos and wfdb.

```python theme={null}
import khaos
import wfdb

ecg = khaos.load("tele_bio_ecg")

scores = {}
for record_id in record_ids:
    record = wfdb.rdrecord(record_id)
    signal = record.p_signal[:, 0]
    scores[record_id] = ecg(signal).anomaly_score

for rid, s in sorted(scores.items(), key=lambda kv: -kv[1])[:3]:
    print(rid, round(s, 2))
# 100_117 0.91
# 100_203 0.84
# 100_048 0.77
```

## Alert on operating regime shifts

**Problem:** know when a plant moves into a different operating mode. **Uses:**
Khaos and the standard library.

```python theme={null}
import khaos
import logging

shift = khaos.load("tele_regime_shift")
points = shift(sensor_history).change_points

for i in points:
    logging.warning("regime change at sample %d (%s)", i, timestamps[i])
# WARNING regime change at sample 4810 (2026-03-02 06:14:00)
# WARNING regime change at sample 9335 (2026-03-02 11:02:10)
```

## Inputs and outputs for each model

These are real outputs of the v1 models, run through their exported ONNX files on held-out examples. The shapes listed are the exact ONNX inputs and outputs; `batch` and other named sizes are dynamic.

### `tele_sensor_vibration`

A 3,200-sample vibration window, shape (1, 1, length), in. The model returns an embedding and an anomaly score: the reconstruction error (higher means more unusual). Raw sensor units are fine; each window is normalized inside the model.

**Model inputs:** `x float32 [batch, 1, 3200]`\
**Model outputs:** `vector float32 [batch, 128]; anomaly_score float32 [batch]`

**Input**

```python theme={null}
x.shape = (1, 1, 3200)   # two windows, one normal and one abnormal
threshold = 0.9777003139257431
```

**Output**

```json theme={null}
{
  "normal_window": {
    "label": "normal",
    "anomaly_score": 0.453,
    "embedding": [
      0.008,
      0.109,
      -0.082,
      0.023,
      -0.146,
      0.28,
      "..."
    ]
  },
  "abnormal_window": {
    "label": "ball",
    "anomaly_score": 0.99,
    "embedding": [
      -0.31,
      0.962,
      0.192,
      -0.409,
      -0.371,
      0.789,
      "..."
    ]
  }
}
```

### `tele_bio_ecg`

A 2,048-sample ecg window, shape (1, 1, length), in. The model returns an embedding and an anomaly score: the probability that the window is abnormal. Raw sensor units are fine; each window is normalized inside the model.

**Model inputs:** `x float32 [batch, 1, 2048]`\
**Model outputs:** `vector float32 [batch, 128]; anomaly_score float32 [batch]`

**Input**

```python theme={null}
x.shape = (1, 1, 2048)   # two windows, one normal and one abnormal
threshold = 0.38929773598909356
```

**Output**

```json theme={null}
{
  "normal_window": {
    "label": "normal",
    "anomaly_score": 0.542,
    "embedding": [
      -0.057,
      -1.298,
      -0.39,
      -0.158,
      -0.17,
      0.094,
      "..."
    ]
  },
  "abnormal_window": {
    "label": "abnormal_beat",
    "anomaly_score": 0.943,
    "embedding": [
      0.584,
      -1.962,
      -1.26,
      0.547,
      0.516,
      -0.756,
      "..."
    ]
  }
}
```

### `tele_regime_shift`

A multivariate window (8 channels x 512 samples; streams with fewer channels are zero-padded) in, one change probability per 8-sample patch out (64 values). Patches above the threshold are where the regime is predicted to change.

**Model inputs:** `x float32 [batch, 8, 512]`\
**Model outputs:** `change_logits float32 [batch, 64]`

**Input**

```python theme={null}
x.shape = (1, 8, 512)   # wearable-sensor stream spliced between two activities
threshold = 0.050
```

**Output**

```json theme={null}
{
  "patches_above_threshold": [
    16,
    32,
    48
  ],
  "true_change_patches": [
    16,
    32,
    48
  ],
  "top_probability": 0.998
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.