GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - CJX0712/changeforge: ChangeForge: 变化点检测(Changepoint Detection)工程框架 — 纯 numpy 离线兜底 + ruptures 后端 + ConStab-CPD 旗舰共识集成。

BranchesTags
Open more actions menu

Latest commit

 

History

7 Commits
7 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
artifacts
artifacts
 
 
changeforge
changeforge
 
 
docs
docs
 
 
examples
examples
 
 
scripts
scripts
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 
requirements.lock.txt
requirements.lock.txt
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

ChangeForge

变化点检测(Changepoint Detection)工程框架 —— 从合成数据生成到检测、评测、超参搜索、基准落盘的一体化流水线。

  • 作者:晨星
  • 域:时间序列 / 信号的变化点检测(均值漂移、方差切换、趋势切换)
  • 技术栈:Python 3.13 · numpy · scipy · scikit-learn · ruptures · Optuna · ruff · pytest
  • 状态:算法与基准已产出(12 个检测器 + ConStab-CPD 旗舰,纯 numpy 离线兜底 + ruptures 后端)

快速开始

# 1) 创建虚拟环境并安装(Windows 用 .venv\Scripts\python.exe)
python -m venv .venv
.venv/Scripts/python -m pip install -r requirements.txt
.venv/Scripts/python -m pip install -e .

# 2) 冒烟:查看环境与配置
python -m changeforge.cli info

# 3) 端到端演示(落盘 artifacts/benchmark.json)
python examples/run_demo.py

# 4) 跑测试与静态检查
python -m pytest tests -q
python -m ruff check .

Docker:

docker build -t changeforge:0.1.0 .
docker run --rm changeforge:0.1.0 info

命令行

子命令 作用
info 打印版本、配置、环境、已注册检测器
list-detectors 列出已注册检测器
list-datasets 列出合成数据类型
gen 生成合成数据并导出 CSV(含 is_change 真值列)
run 单数据集端到端:检测 + 评测(--json 输出结构化结果)
benchmark 多数据集 × 多检测器基准,落盘 benchmark.json
tune Optuna 调参(--space 指定搜索空间 JSON)

配置可通过环境变量覆盖,前缀 ENV_CHANGEFORGE_,例如:

ENV_CHANGEFORGE_SEED=7 ENV_CHANGEFORGE_TOLERANCE=12 python -m changeforge.cli info

优先级:默认值 < 环境变量 < 显式参数/--config 配置文件。

目录结构

changeforge/                 # 仓库根
├── changeforge/             # 包
│   ├── core/                # 类型 · 错误码(E100~E500) · 配置 · 协议 · 校验
│   ├── data/                # 合成数据生成(含真值)+ CSV/NPY 载入
│   ├── detectors/           # 变化点检测器注册表(算法模块待接入)
│   ├── hpo/                 # Optuna 调参
│   ├── eval/                # 评测指标(容差匹配 P/R/F1 · MAE · ARI)
│   ├── pipeline/            # ChangeForgePipeline.run() + benchmark()
│   └── cli.py               # argparse 入口
├── examples/run_demo.py     # 端到端演示
├── tests/                   # pytest
├── docs/architecture.md     # 架构说明
└── Dockerfile / Makefile / pyproject.toml / requirements*.txt

架构与扩展方式见 docs/architecture.md。

性能基准(quick 冒烟,确定性可复现)

口径:主指标 F1@tol_rel(tol_rel = 0.01·n);β = lam·d·σ̂²·log n,σ̂ = MAD·1.4826,lam=3(BIC 类默认)。 旗舰 ConStab-CPD 用 n_perm=19 循环块置换显著性闸门(conformal p≤α 才报警); quick 档为降速版(减少每档序列数),完整数字见 artifacts/benchmark.json,区分度自检见 artifacts/dgp_calibration.json。

检测能力(非空档 · F1@A / F1@C / P / R / 单次时延 ms)

口径 A:tol = 0.01·n(行业常见);口径 C:tol = 0.1·n/(K_true+1),即 tol/平均段长恒为 0.1,跨档可比。 A 口径下 tol/段长 = 0.01·K,密集变点档(D5, K=20)被容差"送分";机理详见 docs/difficulty_analysis.md。

档 检测器 F1@A F1@C P R 时延ms
D0 Smoke numpy-pelt-l2 1.000 1.000 1.000 1.000 28.4
D0 Smoke numpy-binseg-l2 1.000 1.000 1.000 1.000 20.1
D0 Smoke numpy-window-l2 0.667 0.667 0.500 1.000 16.1
D0 Smoke numpy-mmd-rff 1.000 1.000 1.000 1.000 475.4
D0 Smoke numpy-cusum 0.417 0.417 0.267 1.000 0.7
D0 Smoke numpy-slidingt 0.667 0.667 0.500 1.000 23.3
D0 Smoke ruptures-pelt-l2 1.000 1.000 1.000 1.000 3427.9
D0 Smoke ruptures-pelt-l1 1.000 1.000 1.000 1.000 4644.7
D0 Smoke ruptures-pelt-normal 1.000 1.000 1.000 1.000 5433.8
D0 Smoke ruptures-pelt-rank 1.000 1.000 1.000 1.000 5051.1
D0 Smoke ruptures-kernel-rbf 1.000 1.000 1.000 1.000 21.6
D0 Smoke constab-cpd ⭐旗舰 1.000 1.000 1.000 1.000 93009.1
D3 Medium numpy-pelt-l2 0.333 0.500 0.500 0.250 21.7
D3 Medium numpy-binseg-l2 0.167 0.333 0.250 0.125 27.0
D3 Medium numpy-window-l2 0.000 0.000 0.000 0.000 13.8
D3 Medium numpy-mmd-rff 0.000 0.200 0.000 0.000 1054.8
D3 Medium numpy-cusum 0.444 0.556 0.400 0.500 0.7
D3 Medium numpy-slidingt 0.000 0.000 0.000 0.000 19.4
D3 Medium ruptures-pelt-l2 0.333 0.500 0.500 0.250 3872.0
D3 Medium ruptures-pelt-l1 0.000 0.200 0.000 0.000 6547.9
D3 Medium ruptures-pelt-normal 0.333 0.500 0.500 0.250 5801.3
D3 Medium ruptures-pelt-rank 0.167 0.367 0.250 0.125 5807.2
D3 Medium ruptures-kernel-rbf 0.000 0.200 0.000 0.000 17.5
D3 Medium constab-cpd ⭐旗舰 0.286 0.486 0.333 0.250 106634.4
D4 Hard numpy-pelt-l2 0.267 0.267 0.286 0.250 26.9
D4 Hard numpy-binseg-l2 0.167 0.167 0.250 0.125 44.6
D4 Hard numpy-window-l2 0.167 0.167 0.250 0.125 15.0
D4 Hard numpy-mmd-rff 0.000 0.000 0.000 0.000 1140.0
D4 Hard numpy-cusum 0.500 0.500 0.375 0.750 0.8
D4 Hard numpy-slidingt 0.000 0.000 0.000 0.000 25.8
D4 Hard ruptures-pelt-l2 0.182 0.182 0.333 0.125 3318.4
D4 Hard ruptures-pelt-l1 0.222 0.222 1.000 0.125 5781.1
D4 Hard ruptures-pelt-normal 0.400 0.400 1.000 0.250 6717.0
D4 Hard ruptures-pelt-rank 0.222 0.222 1.000 0.125 6715.3
D4 Hard ruptures-kernel-rbf 0.000 0.000 0.000 0.000 18.3
D4 Hard constab-cpd ⭐旗舰 0.000 0.000 0.000 0.000 107341.3
D5 Expert numpy-pelt-l2 0.526 0.526 0.556 0.500 65.7
D5 Expert numpy-binseg-l2 0.625 0.625 0.833 0.500 215.1
D5 Expert numpy-window-l2 0.686 0.629 0.800 0.600 28.7
D5 Expert numpy-mmd-rff 0.182 0.182 1.000 0.100 3290.9
D5 Expert numpy-cusum 0.407 0.407 0.324 0.550 1.4
D5 Expert numpy-slidingt 0.389 0.389 0.438 0.350 42.1
D5 Expert ruptures-pelt-l2 0.606 0.606 0.769 0.500 7268.6
D5 Expert ruptures-pelt-l1 0.261 0.261 1.000 0.150 15674.1
D5 Expert ruptures-pelt-normal 0.333 0.333 1.000 0.200 16628.0
D5 Expert ruptures-pelt-rank 0.182 0.182 1.000 0.100 21941.0
D5 Expert ruptures-kernel-rbf 0.095 0.095 1.000 0.050 72.1
D5 Expert constab-cpd ⭐旗舰 0.095 0.095 1.000 0.050 263153.8

零假设档(D1 / D1b · 每序列假阳率 FPR)

档 检测器 FPR
D1 Null-iid numpy-pelt-l2 0.00
D1 Null-iid numpy-binseg-l2 0.00
D1 Null-iid numpy-window-l2 0.00
D1 Null-iid numpy-mmd-rff 0.00
D1 Null-iid numpy-cusum 0.80
D1 Null-iid numpy-slidingt 0.00
D1 Null-iid ruptures-pelt-l2 0.00
D1 Null-iid ruptures-pelt-l1 0.00
D1 Null-iid ruptures-pelt-normal 0.00
D1 Null-iid ruptures-pelt-rank 0.00
D1 Null-iid ruptures-kernel-rbf 0.00
D1 Null-iid constab-cpd 0.00
D1b Null-AR numpy-pelt-l2 1.00
D1b Null-AR numpy-binseg-l2 1.00
D1b Null-AR numpy-window-l2 1.00
D1b Null-AR numpy-mmd-rff 0.00
D1b Null-AR numpy-cusum 1.00
D1b Null-AR numpy-slidingt 1.00
D1b Null-AR ruptures-pelt-l2 1.00
D1b Null-AR ruptures-pelt-l1 0.00
D1b Null-AR ruptures-pelt-normal 0.20
D1b Null-AR ruptures-pelt-rank 0.00
D1b Null-AR ruptures-kernel-rbf 0.00
D1b Null-AR constab-cpd 0.00

区分度自检(dgp_calibration)

  • D0 Smoke: · best_single=1.000 · spread=0.583 · smoke_min_f1=0.417 · 融合增益=+0.000 · GateB回退=否
  • D1 Null-iid: · 融合增益=+0.000 · GateB回退=否 · FPR=[numpy-pelt-l2=0.00, numpy-binseg-l2=0.00, numpy-window-l2=0.00, numpy-mmd-rff=0.00, numpy-cusum=0.80, numpy-slidingt=0.00, ruptures-pelt-l2=0.00, ruptures-pelt-l1=0.00, ruptures-pelt-normal=0.00, ruptures-pelt-rank=0.00, ruptures-kernel-rbf=0.00, constab-cpd=0.00]
  • D1b Null-AR: · 融合增益=+0.000 · GateB回退=否 · FPR=[numpy-pelt-l2=1.00, numpy-binseg-l2=1.00, numpy-window-l2=1.00, numpy-mmd-rff=0.00, numpy-cusum=1.00, numpy-slidingt=1.00, ruptures-pelt-l2=1.00, ruptures-pelt-l1=0.00, ruptures-pelt-normal=0.20, ruptures-pelt-rank=0.00, ruptures-kernel-rbf=0.00, constab-cpd=0.00]
  • D3 Medium: · best_single=0.444 · spread=0.444 · 融合增益=-0.159 · GateB回退=是
  • D4 Hard: · best_single=0.500 · spread=0.500 · 融合增益=-0.500 · GateB回退=是
  • D5 Expert: · best_single=0.686 · spread=0.591 · 融合增益=-0.591 · GateB回退=是

oracle-K 上界参考(仅供对照,禁止进主表)

  • D0 Smoke: ruptures-dynp-l2 (K=1) F1=1.000 —— oracle-K 上界,非公平对比
  • D3 Medium: ruptures-dynp-l2 (K=4) F1=0.375 —— oracle-K 上界,非公平对比
  • D4 Hard: ruptures-dynp-l2 (K=8) F1=0.250 —— oracle-K 上界,非公平对比
  • D5 Expert: ruptures-dynp-l2 (K=20) F1=0.550 —— oracle-K 上界,非公平对比

状态与 Roadmap

  • 工程骨架:core / data / hpo / eval / pipeline / cli
  • 合成数据(constant / variance / trend / mixed)+ 真值变化点
  • 评测指标与基准落盘(JSON)
  • Optuna 调参基建与 CLI
  • 算法模块接入(12 个检测器 + ConStab-CPD 旗舰,纯 numpy 离线兜底 + ruptures 后端)
  • 基准数据集与真实性能数字(quick 冒烟,见上)
  • 结果可视化(docs/benchmark_report.html,单文件零依赖,一键再生成)
python examples/run_demo.py --quick      # 跑基准,落盘 artifacts/benchmark.json
python scripts/make_report.py            # 读真实 json 生成 docs/benchmark_report.html

许可证

Apache-2.0 · 作者 晨星

About

ChangeForge: 变化点检测(Changepoint Detection)工程框架 — 纯 numpy 离线兜底 + ruptures 后端 + ConStab-CPD 旗舰共识集成。

Topics

algorithmschangepoint-detectionchenxingmachine-learningnumpypythontime-series

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.