feat(#39): 超参包 JSON Schema 校验器(PRD 5.3 模型框架配置化)
新增 core/model-framework/hyperparam.py:超参包(Hyperparam Pack)结构化 校验器,零外部依赖(不依赖 jsonschema),对齐 PRD 5.3「超参包驱动」与 EPIC #5。 校验维度(10 类): - 顶层结构:必填字段 model_id/template/algorithm/features/target; - algorithm:已知算法集合校验(xgboost/lightgbm/dnn/lstm/gnn/ isolation_forest/zscore/linear/ridge),未知项报错并列出已知项 (对齐 PRD「新增结构走 Recipe 插件注册」); - features:非空列表、name 唯一且合法、spec 非空(FeatureSpec 文本 存在性校验,语法由 #35 引擎解释); - objective/hyperparams/train_window/alarm_threshold/drift_check 可选 字段的类型、取值与格式校验(train_window 形如 180d/4w;drift limit 在 (0,1];alarm type 含对应阈值键)。 设计: - validate_pack 返回 ValidationReport(逐条问题,不抛异常),便于配置台 聚合展示;load_pack 校验失败抛 ValueError 供训练/推理流水线 fail-fast。 - validate_pack_file 复用结构校验,文件/JSON 解析错误也记入报告。 测试:tests/test_hyperparam.py 25 用例全绿(合法包/必填缺失/未知算法/ 特征重复与缺 spec/目标函数/train_window 格式/alarm/drift/文件加载与 JSON 解析错误);python -m unittest discover -s tests -v → 25 passed。 close #39
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"model_id": "quality_predict_ti",
|
||||
"template": "iAOP-Template-Ti",
|
||||
"algorithm": "xgboost",
|
||||
"features": [
|
||||
{"name": "EMA_CLF_TEMP_5m", "spec": "EMA(CLF-01.TEMP, 5m)"},
|
||||
{"name": "RollingStd_CL2_10", "spec": "RollingStd(CLF-01.CL2, 10)"},
|
||||
{"name": "ROC_FURNACE_PRESS", "spec": "RateOfChange(CLF-01.PRES)"}
|
||||
],
|
||||
"target": "Ti_purity",
|
||||
"objective": "reg:squarederror",
|
||||
"hyperparams": {"max_depth": 6, "eta": 0.1, "n_estimators": 300},
|
||||
"train_window": "180d",
|
||||
"alarm_threshold": {"type": "zscore", "k": 3.0},
|
||||
"drift_check": {"method": "psi", "limit": 0.2}
|
||||
}
|
||||
Reference in New Issue
Block a user