一键导入
ml
Use when tasks need optional PyCaret model training, ML factor generation, inference wrappers, feature importance, or sparse LASSO weight generation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when tasks need optional PyCaret model training, ML factor generation, inference wrappers, feature importance, or sparse LASSO weight generation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when tasks need factor diagnostics, IC/grouped return analysis, attribution, robustness checks, or time-series distribution and stationarity checks.
Use when tasks need vectorized strategy execution, portfolio weighting, portfolio-level filters, transaction cost helpers, exit A/B analysis, overlay metrics, or multi-strategy return blending.
Use when tasks need strategy-agnostic OHLCV indicators, math utilities, generic factor examples, regime slicing, resampling, or label makers.
Use when tasks need PandaData/PandaAI market data, reference data, adjustment factors, futures tick downloads, or symbol conversion.
Use when tasks need HTML reports, Markdown strategy reports, PNG chart helpers, or report files under the research reports directory.
Use when tasks need reusable research pipeline templates, factor screening, parameter sensitivity sweeps, or strategy comparison.
| name | ml |
| description | Use when tasks need optional PyCaret model training, ML factor generation, inference wrappers, feature importance, or sparse LASSO weight generation. |
ML contains reusable model training, prediction, ML factor, and sparse fitting
helpers. It should produce predictions, ranks, labels, or weight matrices; return
accounting belongs in skills.backtest.
from skills.ml.ml_engine import MLEngine, ModelPredictor
from skills.ml.ml_factor import MLFactorEngine, make_precomputed_factor
from skills.ml.lasso_tracker import lasso_track
| Module | Purpose |
|---|---|
skills.ml.ml_engine | Lazy PyCaret classification/regression engine and inference wrapper |
skills.ml.ml_factor | Compress factor configs into ML-ranked cross-sectional factor pivots |
skills.ml.lasso_tracker | Rolling LASSO sparse index-tracking weight generation |
ML rank factor for ModularBacktester
from skills.compute import indicators as I
from skills.ml.ml_factor import MLFactorEngine, make_precomputed_factor
engine = MLFactorEngine(
data=panel_df,
factor_configs=[
{"func": I.trend_score_v2, "kwargs": {"period": 24}, "name": "trend"},
{"func": I.cci, "kwargs": {"period": 48}, "name": "cci"},
],
model_type="xgboost",
train_mode="rolling",
)
rank_pivot = engine.generate()
ml_factor_fn = make_precomputed_factor(rank_pivot, name="ml_rank")
Sparse index-tracking weights
from skills.ml.lasso_tracker import lasso_track
weights = lasso_track(
etf_returns,
index_returns,
lookback=120,
alpha=1e-5,
rebalance_freq="M",
)
PyCaret classification
from skills.ml.ml_engine import MLEngine
engine = MLEngine(task="classification", model_name="xgboost")
model, metrics = engine.setup_and_train(train_df, target="label")
preds = engine.predict(test_df)