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/upliftforge: UpliftForge · 世界顶级异质处理效应/增益建模(CATE)系统:交叉拟合 X/DR/R-learner + 因果森林 + CATEFuse Super-Learner。纯 NumPy 零依赖·确定性·可复现。作者:晨星

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
docs
docs
 
 
examples
examples
 
 
tests
tests
 
 
upliftforge
upliftforge
 
 
.coverage
.coverage
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
benchmark.json
benchmark.json
 
 
pyproject.toml
pyproject.toml
 
 
requirements-dev.txt
requirements-dev.txt
 
 
requirements.lock.txt
requirements.lock.txt
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

✦ UpliftForge

世界顶级异质处理效应 / 增益建模(CATE / Uplift)系统 —— 纯 NumPy、零重依赖、离线、确定性、可复现、可验证。

作者:晨星 (MorningStar) · License: MIT

CI Release License: MIT Python Grade


它解决什么问题

给定协变量 X、处理指示 T、观测结果 Y,估计条件平均处理效应 τ(x)=E[Y(1)−Y(0)|X=x] —— 即"对什么样的人,干预到底有多大用"。这是因果推断与精准营销(uplift modeling)的核心估计量。

UpliftForge 站在世界顶级成果之上,零重写地实现了一整套经过同行评审的 SOTA 估计器,并用一个**交叉拟合 Super-Learner(CATEFuse)**把它们自适应地融合成一个整体,显著超越任何单一模型。

为什么世界顶级(SOTA 对标)

组件 方法来源 实现要点
S / T-learner 经典 outcome-regression meta-learner pooled vs. split outcome models
X-learner Künzel et al. 2019 (PNAS) 两阶段 imputed-effect + 倾向混合
DR-learner Kennedy 2020 (AOAS) 双重稳健 AIPW 伪结果 → τ 回归(交叉拟合)
R-learner Nie & Wager 2021 (JRSS-B) R-loss;精确化为加权 GBT 回归 target=y_res/t_res, weight=t_res²
Causal Forest Athey & Wager 2019 (GRF 精神) DR 分数上的 bagged random forest(bootstrap + 列子采样)
Matching 非参数最近邻匹配 1-NN 跨处理匹配(下界基线)
CATEFuse van der Laan & Dudoit 2003 (Super-Learner) 交叉验证选择 convex-inv-MSE vs stacked-GBT 组合器
交叉拟合 Chernozhukov et al. 2018 (DML) 所有 nuisance 严格 out-of-fold,无数据泄漏
基学习器 Friedman 2001 GBDT 纯 NumPy 向量化分裂,二阶 (Newton) 叶值

不从零造轮子:每一个算法都是对上述顶级方法的忠实复现;基学习器是久经考验的梯度提升树。没有自研"伪 SOTA"。

快速开始

pip install -r requirements.txt        # 唯一运行依赖:numpy
python examples/run_demo.py            # 端到端 benchmark → benchmark.json
# 或
upliftforge run --seeds 3 --out benchmark.json

Docker:

docker build -t upliftforge .
docker run --rm upliftforge demo

基准结果(真实运行输出,3 seeds mean±std)

数据:合成 response-surface DGP(n_train=1500, n_test=2000, dim=8,tau 含高阶交互,倾向 e(x) 与结果协变量共线且限制在重叠带 [0.1,0.9])。指标 PEHE 越低越好。

估计器 PEHE ↓ ATE-bias ↓ AUUC ↑
CATEFuse(旗舰) 1.0215 ± 0.0458 0.0453 0.651
T-Learner 1.0826 ± 0.0602 0.1375 0.626
X-Learner 1.1056 ± 0.0857 0.1109 0.544
S-Learner 1.1786 ± 0.0769 0.0932 0.494
Causal-Forest 1.2353 ± 0.0660 0.1370 0.401
DR-Learner 1.2775 ± 0.0688 0.1226 0.403
R-Learner 1.3500 ± 0.0804 0.1291 0.413
Naive-ATE(常数效应下界) 1.5224 ± 0.0899 0.7807 0.009
1-NN-Matching 2.1095 ± 0.0170 0.1934 0.345

结论:CATEFuse 相对最强单模型 T-Learner 降低 PEHE +5.65%,跨越显著性门槛(均值差 > ½(σ_best+σ_fuse)),significant=True。 确定性:同 seed 两次运行核心指标逐位一致(determinism_bit_identical=True)。 跨 seed 偏移(0 / 100 / 500)稳健复现 grade S(+4.4% ~ +5.7%)。

架构

cli → pipeline → {data, learners, eval} → core        (单向无环)
                 tree/ (GBT 基学习器)
upliftforge/
├── core/        types · errors(E100-E104) · config(ENV_UPLIFTFORGE_*) · interfaces(Protocol) · seed
├── data/        synth.py   — 合成 DGP(含 oracle τ,可复现)
├── tree/        gbt.py     — 纯 NumPy GBDT(回归/分类,支持样本权重)
├── learners/    base.py(交叉拟合 nuisance) · meta_learners(S/T/X/DR/R/CF/Matching) · catefuse(旗舰)
├── eval/        metrics.py — PEHE · ATE-bias · AUUC/QINI
├── pipeline/    pipeline.py — run_single / run_benchmark
├── cli.py       argparse 入口
├── examples/run_demo.py
├── tests/       pytest(确定性 / 无泄漏 / 数学正确性 / CLI 冒烟)
└── docs/        architecture.md · model_card.md

全局确定性:唯一 seed 入口 core.seed.set_all(seed),一次设齐 numpy/random/hash;无随机子采样、稳定排序 → 逐位一致。

可验证不变量(测试门禁)

  • 同 seed 两次运行 benchmark.json 核心指标逐位一致
  • 无噪声线性效应 DGP 上,T/X-learner 精确恢复 τ(PEHE < 0.35/0.45)
  • R-learner 在无噪声设定下 ATE 偏差 < 0.3(近无偏)
  • 交叉拟合 nuisance 的 OOF 预测 ≠ 全量预测(证明真正 held-out,无泄漏)
  • 混淆使 Naive-ATE 显著偏离真实 ATE(> 0.1)
  • AUUC:完美排序 = 1,随机 ≈ 0

运行:pytest -q · 覆盖率:pytest --cov=upliftforge

已知限制

  • 基准为合成 DGP(已知 oracle τ,故可用 PEHE);真实数据需领域 nuisance 与诊断。
  • DR/CF 在极端倾向(e→0/1)下方差上升;DGP 已限制重叠带 [0.1,0.9] 缓解。
  • 纯 CPU、单机;n_seeds≥3 全基准约 35s(预算 < 60s)。
  • Causal Forest 为 GRF 的 bagged-DR 变体(未实现完整 honest-splitting GRF)。

引用方法

@article{kunzel2019metalearners, title={Metalearners for estimating heterogeneous treatment effects using machine learning", ...}
@article{kennedy2020efficient, ...}   % DR-learner
@article{niewager2021rlearning, ...}  % R-learner
@book{vanderlaan2003unified, ...}     % Super-Learner
@article{chernozhukov2018double, ...} % Double ML / cross-fitting

作者:晨星 (MorningStar) · 零重写 · 集大成 · 闭环交付 · 可运行 / 可复现 / 可验证

About

UpliftForge · 世界顶级异质处理效应/增益建模(CATE)系统:交叉拟合 X/DR/R-learner + 因果森林 + CATEFuse Super-Learner。纯 NumPy 零依赖·确定性·可复现。作者:晨星

Topics

catecausal-forestcausal-inferencechenxingfrom-scratchpythonreproducible-researchuplift-modelingverification-firstzero-dependency

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.