ml-model-training
Build and evaluate machine learning models across scikit-learn, PyTorch, and TensorFlow with a structured workflow covering data preparation, feature engineering, model selection, and performance assessment. Learn to handle common pitfalls like data leakage, class imbalance, overfitting, and hyperparameter tuning mistakes through best practices and code examples.
ML Model Training helps you build classification and regression models using scikit-learn, PyTorch, or TensorFlow.
AI-generated summary based on this skill's SKILL.md
Install
secondsky/claude-skills/ml-model-training · repository language: TypeScript
git clone https://github.com/secondsky/claude-skills
cp -r claude-skills/plugins/ml-model-training/skills/ml-model-training ~/.claude/skills/ml-model-trainingnpx skillfed install secondsky/claude-skills/ml-model-trainingFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How to train machine learning models with scikit-learn, PyTorch, or TensorFlow?
ml-model-training covers training workflows across all three frameworks. For scikit-learn, use estimators like LogisticRegression or RandomForest with .fit(). PyTorch requires manual training loops with loss computation and backpropagation. TensorFlow offers high-level APIs via Keras. The skill emphasizes proper data splitting, feature scaling, and validation to ensure robust models across frameworks.
What causes overfitting in neural networks and how do I fix it?
ml-model-training addresses overfitting through regularization (L1/L2), dropout layers, and early stopping. Monitor validation loss during training—if it diverges from training loss, your model is overfitting. Reduce model complexity, increase training data, or apply data augmentation. Early stopping in PyTorch halts training when validation metrics plateau, preventing unnecessary epochs that worsen generalization.
How do I perform hyperparameter tuning and cross-validation?
ml-model-training teaches GridSearchCV and RandomizedSearchCV for systematic hyperparameter search in scikit-learn. Use k-fold cross-validation to assess stability across data splits. For PyTorch/TensorFlow, manually loop over parameter combinations or use Optuna. Cross-validation prevents overfitting to a single train-test split and provides confidence intervals on performance estimates.
How should I prepare data and prevent data leakage in ML?
ml-model-training emphasizes splitting data before any preprocessing to avoid leakage. Fit scalers and encoders only on training data, then transform test data. Handle class imbalance via stratified splits, resampling, or class weights. Never use test information during feature engineering or hyperparameter tuning. Proper train-test-validation separation ensures honest performance estimates.
What are the best practices for evaluating model performance?
ml-model-training covers appropriate metrics: accuracy for balanced data, F1-score or ROC-AUC for imbalanced classification, MAE/RMSE for regression. Use confusion matrices to diagnose false positives/negatives. Always evaluate on held-out test sets, not training data. Report metrics with confidence intervals from cross-validation to demonstrate reproducibility and statistical significance.
How do I debug convergence issues and underfitting in neural networks?
ml-model-training addresses convergence by checking learning rate, batch size, and gradient flow. Underfitting occurs when both training and validation loss remain high—increase model capacity, train longer, or reduce regularization. Use gradient clipping for exploding gradients. Monitor loss curves during training; sudden spikes suggest learning rate too high, while flat curves suggest too low.
SKILL.md
rendered from the published skill — quoted content, verbatim
ML Model Training
Train machine learning models with proper data handling and evaluation.
Training Workflow
- Data Preparation → 2. Feature Engineering → 3. Model Selection → 4. Training → 5. Evaluation
Data Preparation
```python import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, LabelEncoder
Load and clean data
df = pd.read_csv('data.csv') df = df.dropna()
Encode categorical variables
le = LabelEncoder() df['category'] = le.fit_transform(df['category'])
Split data (70/15/15)
X = df.drop('target', axis=1) y = df['target'] X_train, X_temp, y_train, y_temp = train_test_split(X, y,
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 3 files
plugins/ml-model-training/skills/ml-model-training/SKILL.md
plugins/ml-model-training/skills/ml-model-training/references/pytorch-training.md
plugins/ml-model-training/skills/ml-model-training/references/tensorflow-keras.md