/quant-skills:machine-learningfrom quant-skills
Guides building, training, evaluating, debugging, and deploying ML models. Covers scikit-learn, XGBoost, LightGBM, CatBoost, PyTorch, feature engineering, cross-validation, metrics, class imbalance, hyperparameter tuning, overfitting, data leakage, calibration, model serving, and drift monitoring.
Ships in quant-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Most machine learning failures are evaluation failures. The model trains, the number looks good, and the number was measuring the wrong thing: information leaked across the split, the metric did not match the decision, or the test set was used to choose the model. So the evaluation is designed before the model.
Fix the split, the metric and a baseline before any modelling. Fit every data-dependent step inside the training fold. Touch the test set once.
| Data | Split | Why |
|---|---|---|
| Independent rows | stratified K-fold | keeps class balance in every fold |
| Several rows per user, patient, device or document | group K-fold by that entity | the same entity on both sides lets the model memorise it |
| Time-ordered, or predicting the future | time-based: train on the past, test on what follows, with a gap as long as the label horizon | a random split trains on the future |
| Both grouped and time-ordered | split by time, then check no group straddles the boundary | either leak alone is enough to fool you |
| Very small data | repeated or nested cross-validation | one split is mostly noise |
If a random split and a time or group split give very different scores, the lower one is the truth.
| Task | Use | Avoid |
|---|---|---|
| Balanced classification | accuracy plus log loss | accuracy alone |
| Rare positive class | PR-AUC, recall at a fixed precision | accuracy, and ROC-AUC alone (it looks fine at 1% prevalence) |
| Probabilities drive the decision | log loss or Brier score, with a calibration plot | metrics that only rank |
| Ranking or retrieval | NDCG, MAP, recall@k | accuracy |
| Regression | MAE when all errors cost alike, RMSE when large ones cost more | R-squared alone; MAPE when targets are near zero |
| Forecasting | error against a naive forecast (MASE), by horizon | a single number pooled over horizons |
Report the metric with an interval (bootstrap the test set, or use the spread across folds). A difference smaller than the interval is not an improvement.
| Data | Start with | Then |
|---|---|---|
| Tabular, any size | gradient-boosted trees (LightGBM, XGBoost, CatBoost) | linear or logistic regression as the interpretable reference |
| Tabular, small and noisy | regularised linear model | boosted trees with strong regularisation |
| Text | a pretrained transformer, fine-tuned or used for embeddings | TF-IDF plus a linear model as the baseline to beat |
| Images, audio | a pretrained network, fine-tuned | train from scratch only with very large data |
| Time series | seasonal-naive, then boosted trees on lag features | sequence models, when there are many related series |
On tabular data, deep networks rarely beat well-tuned boosted trees. Reach for them when the input is raw signal, text or images.
A score that looks too good is the main symptom. Investigate before celebrating.
Keep the natural class ratio in validation and test data. Then, in order: choose a metric that reflects the rare class, set class weights, and tune the decision threshold on validation data. Resampling such as SMOTE goes inside the pipeline so it touches training folds only, and it distorts predicted probabilities, so recalibrate afterwards. Often class weights plus a tuned threshold is enough.
Tune after the features and the split are settled; a better feature is usually
worth more than any hyperparameter. Use random search or Optuna (TPE) rather
than a grid, with early stopping for boosted trees and networks. For boosted
trees the parameters that matter are learning rate with number of trees, tree
size (num_leaves or max_depth), minimum samples per leaf, and row and column
subsampling. Every configuration tried is a look at the validation set; with
many trials, confirm the winner on fresh folds.
model.train() and model.eval() matter: dropout and batch norm behave
differently, and forgetting eval() silently degrades validation scores.| Symptom | Likely cause | Try |
|---|---|---|
| Train good, validation poor | overfitting | more data, regularisation, simpler model, early stopping |
| Both poor | underfitting, weak features or a bug | check the pipeline end to end, add features, increase capacity |
| Validation good, production poor | leakage, or production data differs from training data | audit the split; compare feature distributions train versus live |
| Loss is NaN | learning rate too high, bad input values, log of zero | lower the rate, check inputs, clip gradients, add epsilon |
| Loss flat from the start | learning rate too low or too high, labels misaligned, frozen parameters | overfit one batch; verify inputs and labels pair up |
| Validation better than training | dropout or augmentation active only in training, or leakage in the validation set | usually benign; rule out leakage |
| Good metric, bad decisions | metric does not match the cost of errors | return to step 1 |
| Slow decay after deployment | drift in inputs or in the input-outcome relationship | monitor, retrain on a schedule or on a trigger |
| File | When |
|---|---|
references/tabular-recipes.md | leak-free scikit-learn pipeline, group and time splits, LightGBM with early stopping, Optuna, calibration and threshold choice, bootstrap intervals |
references/pytorch-training.md | training loop with mixed precision, clipping, scheduler, early stopping and checkpoints; reproducibility; debugging order |
references/production.md | packaging and serving, training-serving skew, drift monitoring, retraining triggers, model card |
For financial time series, the quantitative-finance and hedge-fund-blueprint
skills add purged splits, cost-aware evaluation and multiple-testing corrections.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub ricko12vpl/claude-code-skills --plugin quant-skills9 skills in this plugin
/hedge-fund-blueprintUse when building, planning, reviewing or extending the platform of a systematic (quant) hedge fund or trading operation as a whole - point-in-time data store, backtester, factor risk model, signals, portfolio optimizer, execution and order management, reconciliation, P&L attribution - or when deciding what to build first, which stack to start with, or whether one of those pieces is finished. Triggers - "build a hedge fund / quant fund / trading system from scratch", "what should I build next", research-to-production pipeline, alpha platform architecture, "is my backtester / risk model / optimizer good enough", trade lifecycle from decision to settlement, how the parts of a fund fit together. Use it even when only one piece is named but the user is clearly assembling the full loop./python-programmingUse when writing, reviewing, refactoring or debugging Python code - new modules, scripts or CLIs, type hints, dataclasses and data modelling, error handling, asyncio, pytest tests, project setup with pyproject.toml, tooling (uv, ruff, mypy, pyright), or performance work. Triggers - "write a Python function or class", "add type hints", "make this more Pythonic", "refactor this module", "why is this slow", "set up a Python project", "write tests for this", import or packaging errors, mutable default arguments, async bugs./quantitative-financeUse when working on one quantitative finance or systematic trading problem - designing or checking a backtest, testing a signal or alpha idea, time-series statistics (stationarity, cointegration, mean-reversion half-life, GARCH volatility), factor regressions, portfolio construction (mean-variance, risk parity, Black-Litterman), risk measures (volatility, VaR, expected shortfall, drawdown), position sizing and Kelly, execution schedules, market impact, transaction cost analysis, or computing and interpreting performance numbers such as a Sharpe ratio. Triggers - pairs trading, momentum or mean-reversion strategies, walk-forward optimization, overfitting or look-ahead worries, slippage, order book analysis, "is this result real". For assembling a whole fund platform in build order, use hedge-fund-blueprint./senior-quantitative-developerUse when building, optimizing or hardening trading infrastructure - market data feed handlers, order gateways and routing, pre-trade risk, low-latency hot paths, tick capture and replay - or when the work concerns latency percentiles (P50, P99), jitter, throughput, packet loss, sequence gaps, deterministic recovery, lock-free queues, kernel bypass, clock synchronisation, or production readiness of a trading system (observability, canary release, rollback, incident response). Triggers - "reduce feed handler latency", "tick to trade", "why did P99 spike", "handle exchange gaps", FIX, ITCH, OUCH, kill switch, backpressure./senior-quantitative-researcherUse when researching, validating or documenting a trading signal or systematic strategy to an institutional standard - forming and pre-registering a hypothesis, building features without leakage, walk-forward or purged cross-validation, ablations and sensitivity analysis, capacity and cost modelling, writing a research report, preparing a signal for handover to production, or diagnosing why live results differ from the backtest. Triggers - "alpha research", "is this signal real", "validate my strategy", "factor research", "research memo", "live vs backtest gap", "alpha decay", "how much capital can this take"./senior-quantitative-traderUse when making portfolio-level decisions for a systematic book - allocating risk across strategies or signals, sizing and leverage, hedging factor or market exposure, setting and applying drawdown rules, reviewing performance attribution (alpha versus factor versus cost), deciding whether to scale, cut, pause or retire a strategy, or writing a periodic performance review or decision memo. Triggers - "attribution review", "how much risk should each strategy get", "we are in drawdown, what now", "should we scale this up", "hedge the beta", "risk budget", "quarterly review", "is this strategy broken or unlucky".Other plugins' skills for the same job