Install
openclaw skills install ml-pipelineComplete machine learning pipeline for trading: feature engineering, AutoML, deep learning, and financial RL. Use for automated parameter sweeps, feature cre...
openclaw skills install ml-pipelineUnified skill for the complete ML pipeline within a quant trading research system. Consolidates eight prior skills into a single authoritative reference covering the full lifecycle: data validation, feature creation, selection, transformation, anti-leakage checks, pipeline automation, deep learning optimization, and deployment.
Activate this skill when the task involves any of the following:
Before starting work, collect or confirm:
| Input | Details |
|---|---|
| Objective | Target metric (Sharpe, accuracy, RMSE ...), constraints, time horizon. |
| Data | Symbols / instruments, timeframe, bar type, sampling frequency, data sources. |
| Leakage risks | Point-in-time concerns, survivorship bias, look-ahead in labels or features. |
| Compute budget | CPU/GPU limits, wall-clock budget for AutoML search. |
| Latency | Online vs. offline inference, acceptable prediction latency. |
| Interpretability | Regulatory or research need for explainable features / models. |
| Deployment target | Where the model will run (notebook, backtest harness, live engine). |
price * volume, high / low, close - open.log(volume + 1), spread^2.return_{t-1}, return_{t-5}, etc.(x - rolling_mean) / rolling_std for stationarity.Data leakage is the single most common cause of inflated backtest results. Apply these checks at every pipeline stage:
t+1 or later at prediction time t.df['feat'].rolling(20).mean().shift(1).t reflects what was actually
tradable at that time (delisted stocks, halted symbols removed later).Run before every backtest:
[ ] Labels computed strictly from future returns (no overlap with features)
[ ] All rolling features shifted by at least 1 bar
[ ] Target encoding uses in-fold means only
[ ] Walk-forward or purged CV used (no random shuffle on time-series)
[ ] Embargo gap >= max(label_horizon, autocorrelation_lag)
[ ] Universe is point-in-time (no survivorship bias)
[ ] No global scaling fitted on full dataset (fit on train, transform test)
| Step | Action |
|---|---|
| 1. Define requirements | Problem type, evaluation metric, time/resource budget, interpretability needs. |
| 2. Data infrastructure | Load data, quality assessment, train/val/test split strategy, define feature transforms. |
| 3. Configure AutoML | Select framework, define algorithm search space, set preprocessing steps, choose tuning strategy (Bayesian, random, Hyperband). |
| 4. Execute training | Run automated feature engineering, model selection, hyperparameter optimisation, cross-validation. |
| 5. Analyse & export | Compare models, extract best config, feature importance, visualisations, export for deployment. |
pipeline_config = {
"task_type": "classification", # or "regression", "time_series"
"time_budget_seconds": 3600,
"algorithms": ["rf", "xgboost", "catboost", "lightgbm"],
"preprocessing": ["scaling", "encoding", "imputation"],
"tuning_strategy": "bayesian", # or "random", "hyperband"
"cv_folds": 5,
"cv_type": "purged_kfold", # or "walk_forward"
"embargo_bars": 10,
"early_stopping_rounds": 50,
"metric": "sharpe_ratio", # domain-specific metric
}
automl_config.py -- pipeline configuration.best_model.pkl / .joblib / .onnx -- serialised model.feature_pipeline.pkl -- fitted preprocessing + feature transforms.evaluation_report.json -- metrics, confusion matrix / residuals, feature rankings.deployment/ -- prediction API code, input validation, requirements.txt.For any feature engineering task, follow this sequence:
| Optimizer | Best For | Learning Rate |
|---|---|---|
| Adam | Most cases, adaptive | 1e-3 to 1e-4 |
| AdamW | Transformers, weight decay | 1e-4 to 1e-5 |
| SGD + Momentum | Large batches, fine-tuning | 1e-2 to 1e-3 |
| RAdam | Stability without warmup | 1e-3 |
import pytorch_lightning as pl
class TradingModel(pl.LightningModule):
def configure_optimizers(self):
optimizer = torch.optim.AdamW(self.parameters(), lr=1e-4)
scheduler = torch.optim.lr_scheduler.OneCycleLR(
optimizer, max_lr=1e-3, total_steps=self.trainer.estimated_stepping_batches
)
return [optimizer], [scheduler]
| Problem | Cause | Fix |
|---|---|---|
| AutoML search finds no good model | Insufficient time budget or poor features | Increase budget, engineer better features, expand algorithm search space. |
| Out of memory during training | Dataset too large for available RAM | Downsample, use incremental learning, simplify feature engineering. |
| Model accuracy below threshold | Weak signal or overfitting | Collect more data, add domain-driven features, regularise, adjust metric. |
| Feature transforms produce NaN/Inf | Division by zero, log of negative | Add guards: np.where(denom != 0, ...), np.log1p(np.abs(x)). |
| Optimiser fails to converge | Bad hyperparameter ranges | Tighten search bounds, increase iterations, exclude unstable algorithms. |
All scripts live in scripts/ within this skill directory.
| Script | Purpose |
|---|---|
data_validation.py | Validate input data quality before pipeline execution. |
model_evaluation.py | Evaluate trained model performance and generate reports. |
pipeline_deployment.py | Deploy a trained pipeline to a target environment with rollback support. |
feature_engineering_pipeline.py | End-to-end feature engineering: load, clean, transform, select, train. |
feature_importance_analyzer.py | Analyse feature importance (permutation, SHAP, tree-based). |
data_visualizer.py | Visualise feature distributions and relationships to target. |
feature_store_integration.py | Integrate with feature stores (Feast, Tecton) for online/offline serving. |