Przejdź do treści
Biblioteka skilli
Dane i analityka · Analiza

causal-ts-discovery

/causal-ts-discovery

Odkrywa strukturę przyczynową w danych szeregów czasowych biblioteką causal-ts: graf przyczynowy oraz zależności opóźnień i czasowe dla danych z czujników i sekwencji.

Repozytorium
causal-ts ↗
Licencja
GPL-3.0
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
2
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

GPL-3.0, otwarta.

Co robi i kiedy

Odkrywa strukturę przyczynową w danych szeregów czasowych biblioteką causal-ts: graf przyczynowy oraz zależności opóźnień i czasowe dla danych z czujników i sekwencji.

Oryginalny opis (EN)

Discover causal structure in time-series data with the causal-ts library. Use when the user wants a causal graph, or lead-lag / temporal dependencies, from time-series, sensor, or sequential data. NOT for effect size, ATE, or counterfactuals — that is effect estimation (see the handoff at the end).

Jak działa

  1. 0. Prerequisite
  2. 1. Locate the data and do a health check
  3. 2. Inspect (facts + recommendation, one call)
  4. 3. Cost gate
  5. 4. Run discovery
  6. 5. Interpret the graph
  7. 6. (Optional) Robustness — only with consent
  8. 7. Effects handoff (out of scope here)
Sekcje z nagłówków SKILL.md, w oryginale · 179 linii, 1 323 słów
Podgląd SKILL.md
---
name: causal-ts-discovery
description: >-
  Discover causal structure in time-series data with the causal-ts library.
  Use when the user wants a causal graph, or lead-lag / temporal dependencies,
  from time-series, sensor, or sequential data. NOT for effect size, ATE, or
  counterfactuals — that is effect estimation (see the handoff at the end).
---

# Causal discovery for time series (causal-ts)

Recover the causal graph — who-causes-whom, at which lags — from a multivariate
time series. CLI-first; drop to Python only where noted.

## 0. Prerequisite

The `causal-ts` CLI must be importable. If `causal-ts --help` fails, install with
`pip install causalts` (add `pip install causalts[parquet]` if the data is
parquet/feather).

## 1. Locate the data and do a health check

Identify what the user handed you:

- **A file** (`.csv`, `.parquet`, `.feather`) → use the CLI path (steps 2–4).
- **An in-memory pandas DataFrame** (notebook/session) → use the Python path:
  `from causalts import inspect_df; report = inspect_df(df)`, then jump to step 3
  using `report`. For discovery, `discover_df(df, algorithm=..., ci_test=...,
  max_lag=..., include_C=..., c_preset=...)` is the in-memory twin of the CLI —
  it returns a result object whose `.cg_tig` you can pass to
  `causalts.inspection.edges_from_graph` / `diagnostics_from_graph` to get the
  same edge list and diagnostics §5 expects. It raises rather than silently
  ignoring an argument the chosen algorithm can't honour. Otherwise write the
  frame to a temp file (`df.to_parquet("/tmp/ts.parquet")`) and use the CLI.

## 2. Inspect (facts + recommendation, one call)

```bash
causal-ts inspect <data-file>
```

This prints JSON: `{schema_version, data, facts, recommendation, cost_class,
warnings}`. Read it — do **not** re-derive these facts yourself.

- **`warnings`** — surface every one to the user (missing data, constant columns,
  too-few rows). If a column is heavily missing or constant, recommend fixing it
  (impute/drop) before trusting results.
- **`facts`** — linearity, per-column (non)stationarity + its `form`, suggested
  max lag, and `latent_factor`.
  - **`latent_factor`** — `{detected, spectral_ratio, tau}`. `detected: true` means
    one or more latent factors load broadly across the panel; plan on deconfounding
    (§5). Read the negatives narrowly: `false` only rules out factor structure this
    test can see — a latent cause touching just two or three variables produces no
    dominant eigenvalue and stays invisible — and `null` means the check could not run
    (missing values, `d < 2`, too few rows). **Never report either as "no
    confounding".**
- **`recommendation`** — `{algorithm, ci_test, include_C, c_preset, max_lag,
  rationale}`. This is a deterministic default; you may **override it** with
  context the tool can't see (e.g. the user says "these are already
  differenced/log-returns" → drop the C node; "I only care about causes of Y" →
  see `--target-var` in `causal-ts discover --help`).
- **`cost_class`** — `cheap | moderate | expensive`.

If unsure which CI test fits, run `causal-ts ci-test-info` and read the live guide
rather than guessing.

## 3. Cost gate

- `cost_class == "cheap"` → proceed to discovery without asking.
- `cost_class == "moderate"` → proceed, but tell the user what you're running.
- `cost_class == "expensive"` (large d, `kci`/`cmiknn-gpu`, or GRACE) →
  **checkpoint first.** Tell the user the config and that it may be slow, then
  offer a concrete cheaper alternative — stay **inside causal-ts** (do NOT
  suggest external tools like PCMCI/tigramite; they are optional deps and may be
  absent). Pick the alternative by what makes it expensive:
  - expensive from **GRACE / high `d`** → offer `cdnots` or `cedar` with
    `parcorr-gpu` (same skeleton, no neural-gate training);
  - expensive from the **CI test** (`kci` / `cmiknn-gpu`) → downshift to
    `splitkci`;
  - or lower `--max-lag`.
  Then wait for the go-ahead.

## 4. Run discovery

Use the recommended config. Example:

```bash
causal-ts -o <out-dir> discover <data-file> --json \
  --algorithm <rec.algorithm> --ci-test <rec.ci_test> \
  --max-lag <rec.max_lag> [--include-c --c-preset <rec.c_preset>]
```

`-o` is a **global** option and must come *before* `discover` (same for other
`causal-ts` commands). `--json` echoes the summary (including a named **edge
list**) to stdout — parse that directly. Artifacts (`estimated_graph.npy`,
`summary.json`) are written to the `-o` directory.

## 5. Interpret the graph

Read the `edges` list (`source → target @ lag`, with `pvalue` when present) and
report it in plain English. Apply this diagnostic playbook.

Note on `pvalue`: for the CDNOTS family and CEDAR it is **`null` unless you asked
for it**.
P-values are off by default as a memory safeguard for very high-dimensional data;
pass **`--pvalues`** to `discover` to get them (safe on low/moderate `d` — i.e.
when `cost_class` is `cheap`/`moderate`; skip it on very high `d`). So if the user
wants per-edge p-values and `d` isn't huge, re-run with `--pvalues`. `null` means
"not requested," not "no confidence" and not that the algorithm gates instead of
testing — don't speculate about internals. For a robustness measure (as opposed
to a per-test p-value), use `--validate` (§6).

`discover --json` includes a computed `diagnostics` block (`empty`, `saturated`,
`density`, `self_loops`, `contemporaneous`/`lagged`, `max_in_degree` + `hub`) —
read it rather than eyeballing, then apply:

- **`empty` (no edges)** → alpha may be too strict, max_lag too small, or the
  CI test underpowered for the mechanism. Suggest a looser alpha or a
  higher-recall test (`dfcit`).
- **`saturated` (near-complete graph)** → likely over-connection. Common causes:
  unhandled nonstationarity (was `include_C` set when the data is nonstationary?)
  or near-unit-root persistence. Suggest a stricter alpha (e.g. 0.01),
  differencing, or verifying the C-node preset matches the trend `form`.
- **High `max_in_degree` at `hub`** → inspect whether that variable is a common
  effect or an artifact of a confounder/persistence.
- **Many `contemporaneous` edges, especially with step-2 `latent_factor.detected`**
  → a broadly-loading latent factor induces exactly this signature (lag-0 edges
  among variables with no direct causal link). Offer to correct it:
  `causal-ts deconfound <graph.npy> --data <data-file>` (or `res.deconfound()` in
  Python), which infers whether the confounding is sparse or pervasive and applies
  the matching correction. Report edges-before/after and be explicit that the
  removed edges were **judged confounded, not disproven**. Which edges are eligible
  depends on the inferred regime: the pervasive branch rewrites the lag-0 slice only,
  while the sparse branch also tests lagged edges against observed controls.
- **`lagged` == 0 (all edges contemporaneous)** → check that `max_lag` is
  adequate and the sampling rate isn't washing out dynamics.
- **Self-loops** are autoregressive terms (a variable's own past), expected for
  persistent series — not spurious.
- Lag 0 = contemporaneous; lag k = `source(t-k) → target(t)`.

If the data was flagged nonstationary/short in step 2, caveat the result
accordingly.

**Done when** every edge is stated as `source → target @ lag`, all step-2
warnings are surfaced, and a next step (robustness in §6, or the effects handoff
in §7) is offered.

## 6. (Optional) Robustness — only with consent

If the user wants confidence in the edges and accepts extra runtime, use the
built-in stability check: add **`--validate`** to `discover` (tune with
`--n-bootstrap`, default 20, and `--window-frac`, default 0.6). It re-runs
discovery on contiguous windows and annotates every edge in the JSON with
`persistence` (fraction of windows it recurs) plus a `stability` block:

```bash
causal-ts -o <dir> discover <data> --json --algorithm <rec.algorithm> \
  --ci-test <rec.ci_test> --max-lag <rec.max_lag> --validate
```

Report edges with `persistence >= ~0.6` as stable and the rest as fragile.
`--validate` is **not supported for GRACE** (bootstrapping neural training is
impractical) — validate a GRACE result with `--algorithm cdnots`/`cedar` instead,
or in Python drive `causalts.bootstrap.temporal_bootstrap` with a
`run_cdnots_gated(sub, max_lag=<...>).gate_values` discovery function.

**Caveat: persistence measures robustness to *sampling*, not correctness.** A
*systematic* artifact — e.g. a lag-k edge that is just an echo of a true
lag-(k−1) edge through a feedback loop, or shared autocorrelation — recurs in
every window and so scores high persistence while still being wrong. Read high
persistence as "not a sampling fluke", not "definitely causal"; for a suspected
echo, check whether the lag-k edge survives conditioning on the lag-(k−1) edge
(stricter alpha, or inspect the p-value).
This is more expensive; get consent first, especially when `cost_class` was
`expensive`. Quick alternative: re-run discovery at a stricter alpha and report
which edges survive.

## 7. Effects handoff (out of scope here)

If the user asks **how much** X affects Y, for an ATE, or for counterfactuals —
that is effect *estimation*, not discovery. Don't do it in this skill. Point them
to causal-ts's DoWhy integration:

> causal-ts can estimate that from the discovered graph via its DoWhy bridge —
> see `causal-ts dowhy --help` or `result.estimate_effect(...)` (needs
> `pip install causalts[dowhy]`). Want me to set that up?
Pliki w paczce (2)
  • SKILL.md 9 KB
  • agents/openai.yaml 1 KB

Wersje

W bazie nie ma innych skilli o nazwie causal-ts-discovery.

Migawka bazy z 13.11.2026 · wersja paczki 4032b8cc6e56 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90time-series-data
    Przechowuje dane szeregów czasowych z retencją i downsamplingiem, kompresją, obsługą zdarzeń poza kolejnością i trafnym wyborem magazynu, dla metryk, zdarzeń i strumieni z czujników.
  • 100causal-report
    Kompiluje analizę przyczynową w ustrukturyzowany raport z tabelami, wykresami i opisem metod, gotowy do publikacji lub jako streszczenie dla zarządu.
  • 90data-science-causal-inference
    Szacuje efekty przyczynowe metodami DiD, RDD, IV, dopasowania wyników i uplift, z grafami DAG i modelami kontrfaktycznymi.
  • 100causal-planner
    Prowadzi ustrukturyzowany wywiad, który rozpoznaje problem przyczynowy i rekomenduje właściwą metodę wnioskowania wraz z planem analizy krok po kroku, gdy pytanie brzmi, czy X powoduje Y.
  • 90data-science-statistical-analysis
    Analizuje dane statystycznie: testy hipotez, regresję, prognozy szeregów czasowych i wnioskowanie bayesowskie z raportem efektów.
  • 90causal-run
    Wykonuje uzgodnioną analizę przyczynową z pliku JSON i CSV, zapisując foldy, diagnostykę, wersje i pełne wyniki szacunków.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.