Skip to main content

gigi-episodes

Change-point detection for time series. The "when did this break?" tool, as a portable Python library + CLI.

from gigi_episodes import find_changepoints

# Your latency over the last 1000 requests
latencies = [50.1, 49.8, 51.2, ..., 95.1, 96.3, 94.8, ...]

result = find_changepoints(latencies)
print(result.indices)   # [573]  — latency drift started around request 573
print(result.count)     # 1
$ gigi-episodes detect production.csv --column latency_p99
  source:      production.csv
  column:      latency_p99
  backend:     local
  threshold:   3.0
  min_segment: 10
  n_points:    1000
  changepoints: 1

  index    score   mean_before → mean_after
  -----    -----   ---------------------------
    573    12.83     50.247  →   95.103

What it's for

Anywhere you have a sequence of values and want to know when it changed:

  • Ops — when did latency start drifting? When did error rate spike?
  • Test flakiness — when did this test suite start failing?
  • User behavior — when did retention break in this cohort?
  • ML monitoring — when did model accuracy drop?
  • Sensor data — when did the reading shift to a new regime?

gigi-episodes is intentionally narrow: change-point detection in 1-D value sequences, nothing else. Other "EPISODIC" features (multivariate, anisotropic, fiber-bundle native) live in the GIGI engine — gigi-episodes exposes one specific brain primitive as the smallest possible installable tool.

Install

pip install gigi-episodes

Optional: install with the GIGI backend (requires requests):

pip install "gigi-episodes[gigi]"

Quick start

from gigi_episodes import find_changepoints

values = [1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1]
result = find_changepoints(values)

for cp in result.change_points:
    print(f"index {cp.index}: {cp.mean_before:.2f} → {cp.mean_after:.2f} (score {cp.score:.1f})")

# index 6: 1.00 → 5.00 (score 11.7)
# index 12: 5.00 → 1.00 (score 11.7)

CLI

# Detect in a CSV column
gigi-episodes detect data.csv --column latency_ms

# JSON output for piping into other tools
gigi-episodes detect data.csv --column latency_ms --json

# Tune sensitivity
gigi-episodes detect data.csv --column latency_ms --threshold 4.0 --min-segment 30

# Read from stdin
cat values.txt | gigi-episodes detect - --column 0

Tuning

Parameter Default What higher means
threshold 3.0 stricter — fewer (more confident) detections; ~σ units of mean shift
min_segment 10 longer "warm-up" before any detection can fire

Defaults are calibrated for clean operational data (latencies, counts, scores). For very noisy data, raise the threshold to 4.0 or 5.0. For long sequences with slow regime shifts, increase min_segment to 30+.

Two backends

LocalBackend (default) — pure numpy. No external services. Use this 99% of the time.

from gigi_episodes import LocalBackend, find_changepoints

result = find_changepoints(values, backend=LocalBackend())

GigiBackend — calls a running GIGI instance's /brain/episodic endpoint for higher-fidelity detection on multivariate or anisotropic data. Useful when you have data already in GIGI bundles and want the engine's full Kähler-aware Welford fit including L13.3 diagonal-Gaussian and L13.7 denominator-floor stability.

from gigi_episodes import GigiBackend, find_changepoints

backend = GigiBackend(
    url="http://localhost:3142",
    api_key="dev-local",
    bundle="latency_metrics",
    field="p99_ms",
)
result = find_changepoints(backend=backend)

The algorithm

gigi-episodes's local backend uses a windowed two-sample mean-difference test with global-scale floor:

  1. For each candidate split point i, compute the mean of the segment so far (from the last change-point up to i) and the mean of the next window points.
  2. Compute the standard error of the difference: SE = sqrt(var_before/n_before + var_after/n_after).
  3. If |mean_after - mean_before| / SE > threshold, it's a change-point.
  4. Both variances are floored by a global MAD-based sigma estimate, so locally-tiny variance (from short or smooth segments) can't blow up the test statistic.

This is the 1-D specialization of GIGI's /brain/episodic endpoint — one of twelve brain primitives unified by the Friston master equation on a Kähler bundle. gigi-episodes makes this single primitive portable; the eleven others live in GIGI.

License

MIT. Free for any use, commercial or otherwise. See LICENSE.

Related

  • GIGI — the fiber-bundle database engine; gigi-episodes's GigiBackend calls it. EPISODIC is one of twelve brain primitives.
  • DreamData — synthetic-data CLI using GIGI's DREAM primitive. Sibling project.
  • gigi-mind — VS Code extension exposing all twelve brain primitives. Sibling project.

Status

v0.1.0 — stable for the documented surface (1-D LocalBackend + CLI + GigiBackend skeleton). API may evolve in 0.x; will stabilize at 1.0.

Metadata

Release files for gigi-episodes 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gigi-episodes 0.1.0
File Size Uploaded Provenance Actions
gigi_episodes-0.1.0.tar.gz 15.1 kB Without provenance Details for gigi_episodes-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gigi-episodes 0.1.0
File Interpreter ABI Platform Actions
gigi_episodes-0.1.0-py3-none-any.whl Python 3 none any Details for gigi_episodes-0.1.0-py3-none-any.whl

Total release size: 29.7 kB

Release files / gigi_episodes-0.1.0.tar.gz

Download URL gigi_episodes-0.1.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
67977b2d698c01aa1d4572444a054b89d21f2f751437fd77a2a55a9d650ef126
BLAKE2b-256 checksum
How to use checksums
51bc5b831f063a11010a699018b42007defaea156570eaacd51e875d5510928f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / gigi_episodes-0.1.0-py3-none-any.whl

Download URL gigi_episodes-0.1.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2beb6961c73c574ec4717181a9aed76ab957c4985e61dd839889787ee599a0d
BLAKE2b-256 checksum
How to use checksums
68db6219d48eca532f9ad6bf3568e910f7059d5cf86565111effb23223984e98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for gigi-episodes 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page