7 · 同一次分析,如何交付给不同使用者?¶
本批保留 Home Credit 两张 application 表的全部 356,255 条记录。TARGET 来自原比赛训练表,比赛测试表的 48,744 条记录保持 null。APPLY_DATE 是按 ID 稳定散列生成的演示日期。0train 用于拟合和 PSI 基准,1val 用于验证或筛选,2test 与 3oot 用于固定结果的独立复核,4_oot_undue 仅表示比赛未公开标签。日期、元数据和角色映射见输入方案与分区说明。
本批实际结果¶
| 格式 | 共享文件 | 用途 |
|---|---|---|
| HTML | binning.html | 原生分箱图、指标与业务元数据交互 |
| Excel | binning.xlsx | 同批分箱静态工作表 |
| .marsreport | binning.marsreport | 目录、查询、保存统计的导出;附加交叉聚合回放另用 score-cross |
| bounded JSON | agent-context.json | Unicode 字符预算内的目录与证据 |
| TXT | external-agent-task.txt | 外部消费者提示材料;未执行 LLM |
HTML 供人工探索,Excel 交付当前静态公共表,.marsreport 保留目录、参数与查询身份,有限 JSON 提供有范围的证据。
同批工作簿关键值逐项对快照核验。Excel 不执行 HTML 交互,也不依赖旧透视缓存。
默认特征查询的身份列依次为 feature → display_name → dtype → data_source,显式 columns
按请求精确投影。案例 JSON、报告目录和 AI 上下文均由同批真实查询生成;manifest 中的
source_commit 记录生成时的已知 Git 基线,代码指纹记录实际用于生成的工作树实现。
cases.zip 只包含明确允许的统计产物与源码,个人写作 Skill、原始 CSV、清洗宽表、样本 ID 明细均不进入公共材料。
无原数据可加载现成快照并重放查询;完整复算须自行取得三个官方文件并传路径。
| 读者用途 | 文件 |
|---|---|
| 原生分箱与质量 | 分箱 HTML / 画像 HTML |
| 当前静态数值 | 分箱 Excel / 规则 Excel |
| 新进程继续查询 | 分箱快照 / 规则快照 |
| 路径、哈希与字典 | manifest / 业务字段字典 |
| 完整允许产物与源码 | cases.zip / 无 CSV 外部任务 |
从报告查看真实表与图,按实际分母判断。完整可运行代码使用共享准备入口,复用同一宽表与固定参考样本。
def _delivery(output: Path) -> None:
"""同批 HTML、Excel 和可查询快照分别交付,核对 Excel 实际数值。"""
import openpyxl
report = load_report(output / "binning.marsreport")
workbook = openpyxl.load_workbook(output / "binning.xlsx", read_only=True, data_only=True)
rows = workbook["001_detail"].iter_rows(values_only=True)
header = list(next(rows))
excel_sample = next(rows)
table_sample = report.get_table("detail", limit=1).row(0, named=True)
for name in ("count", "observed_count", "bad", "bad_rate"):
expected, actual = table_sample[name], excel_sample[header.index(name)]
assert actual == expected or (actual is not None and expected is not None and np.isclose(actual, expected)), name
sheet_names = workbook.sheetnames
workbook.close()
prompt = (
"用 load_report('binning.marsreport') 读取可信快照,describe 查看目录、单位与来源。\n"
"query_page('detail', features='EXT_SOURCE_2', filters={'mars_group':'1val'}, limit=3),按 next_offset 继续。\n"
"引用 reference,区分 count 与 observed_count;坏率是 observed 分母下的比例。\n"
"4_oot_undue 标签未公开;APPLY_DATE 是模拟日期;外部来源分不是校准概率。\n"
"to_ai_context 预算是 Unicode 字符。无需内置 mars.agent、LLM 或原始 CSV。\n"
)
(output / "external-agent-task.txt").write_text(prompt, encoding="utf-8")
formats = [
{"format": "HTML", "path": "binning.html", "use": "原生分箱图、指标与业务元数据交互"},
{"format": "Excel", "path": "binning.xlsx", "use": "同批分箱静态工作表"},
{"format": ".marsreport", "path": "binning.marsreport", "use": "目录、查询、保存统计的导出;附加交叉聚合回放另用 score-cross"},
{"format": "bounded JSON", "path": "agent-context.json", "use": "Unicode 字符预算内的目录与证据"},
{"format": "TXT", "path": "external-agent-task.txt", "use": "外部消费者提示材料;未执行 LLM"},
]
_case(output, 7, report, "同一次分箱分析怎样交付给不同使用者?", [_query(report, "detail", "Excel 首行实际值与快照对齐", limit=1)], {
"formats": formats, "excel_sheets": sheet_names, "excel_key_values_match": True, "shared_cases": [2, 6, 7],
}, "Excel 不恢复交互计算;快照不恢复任意 Python 对象。")
新进程按目录读取已保存统计;实际有限 JSON 中的引用可重放。
from mars.reporting import load_report
report = load_report("binning.marsreport")
print(report.describe())
page = report.query_page("summary", features="EXT_SOURCE_2", limit=3)
print(page["reference"], page["data"])
实际查询结果与分页引用
{
"case": 7,
"report_id": "d73396cc-4ad6-493e-a69a-0cd2a0a435e6",
"consumer": "deterministic public API queries; no LLM",
"question": "同一次分箱分析怎样交付给不同使用者?",
"query": {
"question": "Excel 首行实际值与快照对齐",
"reference": {
"report_id": "d73396cc-4ad6-493e-a69a-0cd2a0a435e6",
"table": "detail",
"query": {
"offset": 0,
"limit": 1
}
},
"total_rows": 3257,
"returned_rows": 1,
"omitted_rows": 3256,
"next_offset": 1,
"rows": [
{
"y": "TARGET",
"feature": "AMT_ANNUITY",
"display_name": "贷款年金",
"dtype": "Float64",
"data_source": "Home Credit 2018 application_{train|test}.csv",
"trend": "peak",
"mars_group": "0train",
"bin_index": 0,
"bin_label": "00_[-inf, 16,515)",
"count": 53823.0,
"observed_count": 53823.0,
"bad": 3800.0,
"good": 50023.0,
"pct": 0.2499048167373952,
"bad_rate": 0.07060178733998476,
"lift": 0.8706435354000479,
"cum_count": 53823.0,
"cum_observed_count": 53823.0,
"cum_bad": 3800.0,
"cum_bad_rate": 0.07060178733998476,
"psi_bin": 0.0,
"ks_bin": 3.521493713732288,
"auc_bin": 0.02749724608806191,
"iv_bin": 0.005272458307445049,
"total_count": 215374.0,
"bin_type": "首尾组",
"tot_amt": 12147315133.5,
"good_amt": 11285842158.0,
"bad_amt": 861472975.5,
"avg_amt": 225690.042054512,
"amt_bad_rate": 0.07091879695491066,
"lift_amt": 0.9399693647747305
}
]
},
"unavailable": "Excel 不恢复交互计算;快照不恢复任意 Python 对象。"
}
运行与下载¶
python docs/snippets/task_cases.py --case 7 --data-dir examples/home-credit-2018/data/raw_data --output-dir output/task-cases
首次生成全部关联证据用 --case all。文件缺失会明确失败,正式入口不回退合成数据。 数据下载与输入准备 · 完整共享源码 · 共享包 · 来源和哈希 · 案例索引