| name | machine-learning-engineer |
| description | Expert ML engineering skill covering the full lifecycle — data ingestion, feature engineering, model training, evaluation, MLOps, and production deployment. Covers classical ML (scikit-learn, XGBoost) AND deep learning (PyTorch, CNNs, transformers, LoRA/QLoRA, LLMs). Trigger on building ML pipelines, training/evaluating models, experiment tracking, model versioning/deployment, drift detection, hyperparameter tuning, PyTorch training loops, fine-tuning BERT or LLMs, building CNNs, LoRA fine-tuning, MLflow setup, DVC, BentoML, FastAPI serving, or any MLOps question. Use for architecture decisions around PyTorch, scikit-learn, XGBoost, Hugging Face Transformers, PEFT, TRL, Kubeflow, or any ML framework. |
Machine Learning Engineer Skill
Overview
This skill guides Claude through end-to-end ML engineering workflows — from problem framing and data processing through model training, evaluation, and production deployment — following 2025 best practices.
When you use this skill, follow these phases:
- Understand the problem — Frame the ML task correctly before writing any code
- Data & Feature Engineering — Build robust, reproducible data pipelines
- Model Development — Train, tune, and evaluate models systematically
- MLOps & Experiment Tracking — Log everything; version data, code, and models
- Deployment & Serving — Package and deploy models safely to production
- Monitoring & Maintenance — Detect drift and trigger retraining
For deep guidance on each phase, read the reference files below.
Quick Reference: ML Engineering Checklist
Problem Framing (Do First!)
Data Pipeline
Model Training
Evaluation
MLOps & Versioning
Deployment
Monitoring
Deep Learning / Transformers (additional checks)
Core Technology Stack (2025)
| Category | Recommended Tools |
|---|
| Languages | Python 3.11+, SQL |
| Classical ML | scikit-learn, XGBoost, LightGBM |
| Deep Learning | PyTorch 2.x, torchvision, torchaudio |
| Transformers / LLMs | Hugging Face Transformers, PEFT (LoRA/QLoRA), TRL, vLLM |
| Experiment Tracking | MLflow (default), Weights & Biases |
| Data Versioning | DVC, lakeFS, Feast (feature store) |
| Pipeline Orchestration | Airflow, Kubeflow Pipelines, Prefect |
| Model Serving | FastAPI, BentoML, TorchServe, Ray Serve, vLLM |
| Containerization | Docker, Kubernetes |
| Cloud ML Platforms | AWS SageMaker, GCP Vertex AI, Azure ML |
| Monitoring | Evidently AI, Prometheus, Grafana |
| CI/CD | GitHub Actions, GitLab CI |
Workflow: End-to-End ML Project
Phase 1 — Problem Setup
ml_project/
├── data/
│ ├── raw/
│ ├── processed/
│ └── features/
├── notebooks/
├── src/
│ ├── data/
│ ├── features/
│ ├── models/
│ ├── evaluation/
│ └── serving/
├── tests/
├── configs/
├── dvc.yaml
├── params.yaml
└── MLproject
Phase 2 — Data & Feature Engineering
See: references/feature-engineering-guide.md
See script: scripts/feature_pipeline.py
Key principles:
- Always build a scikit-learn Pipeline — prevents train-serve skew
- Never fit on validation/test data — fit transformers on train only, transform all splits
- Log feature statistics after engineering to catch distribution drift early
- Use DVC to version both raw data and engineered features as separate pipeline stages
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
preprocessor = ColumnTransformer([
("num", StandardScaler(), numeric_features),
("cat", OneHotEncoder(handle_unknown="ignore"), categorical_features),
])
pipeline = Pipeline([
("preprocessor", preprocessor),
("model", XGBClassifier(**params)),
])
pipeline.fit(X_train, y_train)
Phase 3 — Experiment Tracking
See: references/mlops-tools-and-workflow.md
See script: scripts/experiment_tracking.py
Non-negotiable logging checklist per run:
- Hyperparameters and model architecture
- Dataset version (DVC commit hash or feature store version)
- Git commit hash
- All evaluation metrics (train + val + test)
- Model artifact (registered, not just saved locally)
- Runtime environment (Python version, key package versions)
import mlflow
mlflow.set_tracking_uri("http://mlflow.internal:5000")
mlflow.set_experiment("fraud-detection-v3")
with mlflow.start_run(tags={"git_commit": get_git_hash()}):
mlflow.log_params(params)
mlflow.log_param("dataset_version", dvc_dataset_hash())
mlflow.log_metrics({"auc": auc, "f1": f1, "precision": precision})
mlflow.sklearn.log_model(pipeline, "model",
signature=infer_signature(X_train, y_pred))
Phase 4 — Model Evaluation
See: references/model-evaluation-and-deployment.md
See script: scripts/model_evaluation.py
Always ask:
- What is the null baseline? (predict the majority class, predict the mean)
- What is the business cost of FP vs FN?
- Does performance degrade on subgroups (demographic, temporal, geographic)?
- What's the 95th percentile inference latency?
Phase 5 — Deployment
See: references/model-evaluation-and-deployment.md
from fastapi import FastAPI
import mlflow.pyfunc
app = FastAPI()
model = mlflow.pyfunc.load_model("models:/FraudDetector/Production")
@app.post("/predict")
def predict(features: dict):
import pandas as pd
df = pd.DataFrame([features])
prediction = model.predict(df)
return {"prediction": prediction.tolist()}
@app.get("/health")
def health():
return {"status": "ok"}
Phase 6 — Deep Learning & Transformers
For unstructured data (text, images, audio) or state-of-the-art performance, use neural networks and pre-trained foundation models.
See: references/deep-learning-and-transformers.md
See script: scripts/neural_network_training.py
Decision guide:
- Tabular data (<1M rows) → XGBoost / LightGBM first; MLP only if tree models plateau
- Text tasks → Fine-tune a Hugging Face transformer (distilbert → roberta-large → LLM)
- Image tasks → Fine-tune ResNet/EfficientNet; use YOLO for detection
- LLM fine-tuning → Use LoRA (full GPU) or QLoRA (consumer GPU, 4-bit)
device = get_device()
model.train()
optimizer.zero_grad(set_to_none=True)
with autocast(device_type="cuda", enabled=device.type == "cuda"):
logits = model(X.to(device))
loss = criterion(logits, y.to(device))
scaler.scale(loss).backward()
scaler.unscale_(optimizer)
torch.nn.utils.clip_grad_norm_(model.parameters(), 1.0)
scaler.step(optimizer)
scaler.update()
from peft import LoraConfig, get_peft_model
lora_config = LoraConfig(r=16, lora_alpha=32, target_modules=["query", "value"])
model = get_peft_model(base_model, lora_config)
Common Pitfalls to Avoid
| Pitfall | Prevention |
|---|
| Data leakage | Fit all transformers only on training data; use Pipeline |
| Training-serving skew | Use the same Pipeline object in training and serving |
| Test set contamination | Use test set exactly once, at the end |
| Ignoring class imbalance | Use stratified splits; try class_weight="balanced" |
| Not versioning data | Track all datasets with DVC from day one |
| Models with no lineage | Always register in MLflow with full metadata |
| No monitoring in prod | Deploy drift detection alongside every model |
| Magic numbers in code | All hyperparameters in params.yaml, not hardcoded |
| Notebooks in production | Convert notebooks to .py scripts for pipelines |
| Silent failures | Add schema validation at pipeline inputs/outputs |
Reference Files
Read these files for detailed guidance on specific topics:
references/feature-engineering-guide.md — Encoding, scaling, imputation, feature selection, time-series features, handling high cardinality
references/mlops-tools-and-workflow.md — MLflow setup, DVC pipelines, model registry, CI/CD for ML, drift detection with Evidently
references/model-evaluation-and-deployment.md — Metrics deep-dive, evaluation strategies, deployment patterns, monitoring setup
references/deep-learning-and-transformers.md — PyTorch training loop, CNN/MLP/Transformer architectures, LoRA/QLoRA fine-tuning, training stability, distributed training, debugging
Scripts
Ready-to-use scripts for common ML engineering tasks:
scripts/feature_pipeline.py — End-to-end feature engineering pipeline with scikit-learn
scripts/experiment_tracking.py — MLflow experiment tracking template with full logging
scripts/model_evaluation.py — Comprehensive model evaluation with metrics, plots, and error analysis
scripts/neural_network_training.py — Production PyTorch training loop with mixed precision, early stopping, and Hugging Face fine-tuning (LoRA/QLoRA)