Perform classical machine learning tasks including classification, regression, clustering, and dimensionality reduction using Python.
- GitHub stars
- 86
- Files
- 12
- Last commit
- Nov 11, 2026
- License
- MIT
- Allowed tools
- 5
What does the alterlab-scikit-learn skill do?
alterlab-scikit-learn is an agent skill. Perform classical machine learning tasks including classification, regression, clustering, and dimensionality reduction using Python.
Summary generated from the skill's SKILL.md.
About the alterlab-scikit-learn skill
Performing classical machine learning tasks like classification, regression, and clustering is what this skill enables for developers working with Python. It provides a structured way to implement supervised and unsupervised learning algorithms, ranging from linear models and decision trees to K-Means and PCA. An agent should load this skill when a user needs to build predictive models, preprocess tabular or text data, or evaluate model performance using cross-validation and hyperparameter tuning.
The skill operates locally using the uv package manager to run Python scripts with scikit-learn versions 1.8 or higher. It relies on tools like pandas for data handling and can include matplotlib or seaborn for visualization. Users can build production-ready workflows by utilizing pipelines and column transformers to prevent data leakage. This skill is specifically designed for interpretable, classical approaches rather than Bayesian modeling or specialized survival analysis.
What an agent can do with it
- 1Build predictive classification modelsCreate a system to detect spam or fraudulent transactions using supervised learning algorithms.
- 2Automate data preprocessing workflowsTransform raw datasets by scaling features and encoding categorical variables for machine learning.
- 3Perform customer segmentationGroup unlabeled user data into distinct clusters to identify different consumer behaviors.
- 4Optimize model hyperparametersFind the best settings for a model using grid search or random search techniques.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the alterlab-scikit-learn skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the alterlab-scikit-learn skill in Plugin
/plugin marketplace add AlterLab-IEU/AlterLab-Academic-Skills /plugin install alterlab-data-science@alterlab-academic-skills
Install the alterlab-scikit-learn skill in Claude Code
~/.claude/skills/alterlab-scikit-learn/SKILL.md
$ npx degit AlterLab-IEU/AlterLab-Academic-Skills/skills/data-science/alterlab-scikit-learn ~/.claude/skills/alterlab-scikit-learnInstall the alterlab-scikit-learn skill in Claude Code (project)
.claude/skills/alterlab-scikit-learn/SKILL.md
$ npx degit AlterLab-IEU/AlterLab-Academic-Skills/skills/data-science/alterlab-scikit-learn .claude/skills/alterlab-scikit-learnInstall the alterlab-scikit-learn skill in Codex
~/.agents/skills/alterlab-scikit-learn/SKILL.md
$ npx degit AlterLab-IEU/AlterLab-Academic-Skills/skills/data-science/alterlab-scikit-learn ~/.agents/skills/alterlab-scikit-learnInstall the alterlab-scikit-learn skill in Gemini CLI
~/.gemini/skills/alterlab-scikit-learn/SKILL.md
$ npx degit AlterLab-IEU/AlterLab-Academic-Skills/skills/data-science/alterlab-scikit-learn ~/.gemini/skills/alterlab-scikit-learnInstall the alterlab-scikit-learn skill in Claude.ai
npx degit AlterLab-IEU/AlterLab-Academic-Skills/skills/data-science/alterlab-scikit-learn alterlab-scikit-learn && zip -r alterlab-scikit-learn.zip alterlab-scikit-learn # claude.ai → Customize → Skills → + → Create skill → Upload a skill → alterlab-scikit-learn.zip
Automated checks
Ran Nov 15, 2026Full report →Passed our automated checks. That is not a security audit: read the scripts before you let an agent run them. How checks work
- Source repository linked and reachablealterlab-ieu/alterlab-academic-skills/skills/data-science/alterlab-scikit-learn is public and reachablegithub.com/alterlab-ieu/alterlab-academic-skills/tree/HEAD/s ↗Pass
- Open source license (OSI)MITspdx.org/licenses/MIT.html ↗Pass
- Commit or release in the last yearLast commit 2026-11-11github.com/alterlab-ieu/alterlab-academic-skills/commits ↗Pass
- No download-and-run or credential theft in scripts2 scripts read; no download-and-run, remote eval, base64 execution or credential uploadPass
- No hidden instructions in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/alterlab-ieu/alterlab-academic-skills/blob/HEAD/s ↗Pass
- Pre-approved tools are scopedPre-approved: Read, Write, Edit, Bash(python:*), Bash(uv:*)github.com/alterlab-ieu/alterlab-academic-skills/blob/HEAD/s ↗Pass
- SKILL.md follows the Agent Skills formatValid name and description; says when to use it; 295 linesgithub.com/alterlab-ieu/alterlab-academic-skills/blob/HEAD/s ↗Pass
SKILL.md
View on GitHubScikit-learn
Overview
This skill provides comprehensive guidance for machine learning tasks using scikit-learn, the industry-standard Python library for classical machine learning. Use this skill for classification, regression, clustering, dimensionality reduction, preprocessing, model evaluation, and building production-ready ML pipelines.
Installation
# No install step: uv resolves the packages per call (scikit-learn >= 1.8 needs Python >= 3.11)
uv run --python ">=3.12" --with "scikit-learn>=1.8" --with pandas python pipeline.py
# Optional plotting dependencies
uv run --python ">=3.12" --with "scikit-learn>=1.8" --with pandas --with matplotlib --with seaborn python pipeline.py
When to Use This Skill
Use the scikit-learn skill when:
- Building classification or regression models
- Performing clustering or dimensionality reduction
- Preprocessing and transforming data for machine learning
- Evaluating model performance with cross-validation
- Tuning hyperparameters with grid or random search
- Creating ML pipelines for production workflows
- Comparing different algorithms for a task
- Working with both structured (tabular) and text data
- Need interpretable, classical machine learning approaches
Does NOT Trigger
| Scenario | Use Instead |
|---|---|
| Bayesian models with posteriors, credible intervals, or MCMC diagnostics | alterlab-pymc |
| Censored time-to-event outcomes (Cox models, survival forests, C-index) | alterlab-scikit-survival |
UMAP embeddings with n_neighbors / min_dist tuning |
alterlab-umap |
| Explaining a fitted model's predictions with SHAP values and plots | alterlab-shap |
| Coefficient tables, p-values, and residual diagnostics for inference | alterlab-statsmodels |
Hand-off rule. When the request matches a row above, open your answer by naming that skill by its exact id (for example alterlab-pymc) and saying in one line why it fits better, then stop applying this skill's procedure. Name it even when you also need to ask for missing input. If only part of the request is out of scope, name the skill for that part and do only the in-scope part. A brief general pointer is fine; the named skill does the work.
Quick Start
Minimal classification flow: stratified train_test_split → StandardScaler (fit on train only) → fit estimator → classification_report. For mixed numeric/categorical data, wrap preprocessing in a ColumnTransformer inside a Pipeline so it cross-validates without leakage.
See references/worked_examples.md for full copy-paste classification and mixed-data pipeline examples.
Core Capabilities
1. Supervised Learning
Comprehensive algorithms for classification and regression tasks.
Key algorithms:
- Linear models: Logistic Regression, Linear Regression, Ridge, Lasso, ElasticNet
- Tree-based: Decision Trees, Random Forest, Gradient Boosting
- Support Vector Machines: SVC, SVR with various kernels
- Ensemble methods: AdaBoost, Voting, Stacking
- Neural Networks: MLPClassifier, MLPRegressor
- Others: Naive Bayes, K-Nearest Neighbors
When to use:
- Classification: Predicting discrete categories (spam detection, image classification, fraud detection)
- Regression: Predicting continuous values (price prediction, demand forecasting)
See: references/supervised_learning.md for detailed algorithm documentation, parameters, and usage examples.
2. Unsupervised Learning
Discover patterns in unlabeled data through clustering and dimensionality reduction.
Clustering algorithms:
- Partition-based: K-Means, MiniBatchKMeans
- Density-based: DBSCAN, HDBSCAN, OPTICS
- Hierarchical: AgglomerativeClustering
- Probabilistic: Gaussian Mixture Models
- Others: MeanShift, SpectralClustering, BIRCH
Dimensionality reduction:
- Linear: PCA, TruncatedSVD, NMF
- Manifold learning: t-SNE, UMAP, Isomap, LLE
- Feature extraction: FastICA, LatentDirichletAllocation
When to use:
- Customer segmentation, anomaly detection, data visualization
- Reducing feature dimensions, exploratory data analysis
- Topic modeling, image compression
See: references/unsupervised_learning.md for detailed documentation.
3. Model Evaluation and Selection
Tools for robust model evaluation, cross-validation, and hyperparameter tuning.
Cross-validation strategies:
- KFold, StratifiedKFold (classification)
- TimeSeriesSplit (temporal data)
- GroupKFold (grouped samples)
Hyperparameter tuning:
- GridSearchCV (exhaustive search)
- RandomizedSearchCV (random sampling)
- HalvingGridSearchCV (successive halving)
Metrics:
- Classification: accuracy, precision, recall, F1-score, ROC AUC, confusion matrix
- Regression: MSE, RMSE, MAE, R², MAPE
- Clustering: silhouette score, Calinski-Harabasz, Davies-Bouldin
When to use:
- Comparing model performance objectively
- Finding optimal hyperparameters
- Preventing overfitting through cross-validation
- Understanding model behavior with learning curves
See: references/model_evaluation.md for comprehensive metrics and tuning strategies.
4. Data Preprocessing
Transform raw data into formats suitable for machine learning.
Scaling and normalization:
- StandardScaler (zero mean, unit variance)
- MinMaxScaler (bounded range)
- RobustScaler (robust to outliers)
- Normalizer (sample-wise normalization)
Encoding categorical variables:
- OneHotEncoder (nominal categories)
- OrdinalEncoder (ordered categories)
- LabelEncoder (encodes the target labels
y, not features) - TargetEncoder (encodes high-cardinality categorical features with cross-fitted target means)
Handling missing values:
- SimpleImputer (mean, median, most frequent)
- KNNImputer (k-nearest neighbors)
- IterativeImputer (multivariate imputation)
Feature engineering:
- PolynomialFeatures (interaction terms)
- KBinsDiscretizer (binning)
- Feature selection (RFE, SelectKBest, SelectFromModel)
When to use:
- Before training any algorithm that requires scaled features (SVM, KNN, Neural Networks)
- Converting categorical variables to numeric format
- Handling missing data systematically
- Creating non-linear features for linear models
See: references/preprocessing.md for detailed preprocessing techniques.
5. Pipelines and Composition
Build reproducible, production-ready ML workflows.
Key components:
- Pipeline: Chain transformers and estimators sequentially
- ColumnTransformer: Apply different preprocessing to different columns
- FeatureUnion: Combine multiple transformers in parallel
- TransformedTargetRegressor: Transform target variable
Benefits:
- Prevents data leakage in cross-validation
- Simplifies code and improves maintainability
- Enables joint hyperparameter tuning
- Ensures consistency between training and prediction
When to use:
- Always use Pipelines for production workflows
- When mixing numerical and categorical features (use ColumnTransformer)
- When performing cross-validation with preprocessing steps
- When hyperparameter tuning includes preprocessing parameters
See: references/pipelines_and_composition.md for comprehensive pipeline patterns.
Example Scripts
Two runnable end-to-end scripts ship with this skill:
python scripts/classification_pipeline.py # mixed-data preprocessing, model comparison, GridSearchCV, evaluation, feature importance
python scripts/clustering_analysis.py # optimal-k search, K-Means/DBSCAN/Agglomerative/GMM comparison, PCA visualization
See references/worked_examples.md for what each script demonstrates and standalone copy-paste versions.
Reference Documentation
This skill includes comprehensive reference files for deep dives into specific topics:
Quick Reference
File: references/quick_reference.md
- Common import patterns and installation instructions
- Quick workflow templates for common tasks
- Algorithm selection cheat sheets
- Common patterns and gotchas
- Performance optimization tips
Supervised Learning
File: references/supervised_learning.md
- Linear models (regression and classification)
- Support Vector Machines
- Decision Trees and ensemble methods
- K-Nearest Neighbors, Naive Bayes, Neural Networks
- Algorithm selection guide
Unsupervised Learning
File: references/unsupervised_learning.md
- All clustering algorithms with parameters and use cases
- Dimensionality reduction techniques
- Outlier and novelty detection
- Gaussian Mixture Models
- Method selection guide
Model Evaluation
File: references/model_evaluation.md
- Cross-validation strategies
- Hyperparameter tuning methods
- Classification, regression, and clustering metrics
- Learning and validation curves
- Best practices for model selection
Preprocessing
File: references/preprocessing.md
- Feature scaling and normalization
- Encoding categorical variables
- Missing value imputation
- Feature engineering techniques
- Custom transformers
Pipelines and Composition
File: references/pipelines_and_composition.md
- Pipeline construction and usage
- ColumnTransformer for mixed data types
- FeatureUnion for parallel transformations
- Complete end-to-end examples
- Best practices
Worked Examples
File: references/worked_examples.md
- Quick-start classification and mixed-data pipeline snippets
- Step-by-step classification model workflow
- Step-by-step clustering analysis workflow
- What each bundled example script demonstrates
Best Practices & Troubleshooting
File: references/best_practices_and_troubleshooting.md
- Pipeline / leakage discipline, fit-on-train-only, stratified splitting
- Random-state reproducibility, metric selection, when to scale features
- Fixes for ConvergenceWarning, overfitting, and large-dataset memory errors
Common Workflows
- Classification model: load data → stratified
train_test_split→ColumnTransformerpreprocessing inside aPipeline→GridSearchCVtuning →classification_reporton the held-out test set. - Clustering analysis:
StandardScaler→ silhouette sweep overkto pickoptimal_k→ fitKMeans→PCA(n_components=2)projection for visualization.
See references/worked_examples.md for the numbered, copy-paste version of each workflow.
Version notes (scikit-learn 1.8–1.9)
LogisticRegression(penalty=...)is deprecated (removed in 1.10): usel1_ratio(0 = L2, 1 = L1, in between = elastic net) andC=np.inffor no penalty.SVC(probability=True)is deprecated (removed in 1.11): wrap the model asCalibratedClassifierCV(SVC(), ensemble=False)when probabilities are needed.MDS(metric=True/False)becamemetric_mds=;HDBSCANwarns unlesscopyis set explicitly.mean_squared_error(..., squared=False)is gone; useroot_mean_squared_error.
Best Practices (essentials)
- Always preprocess inside a
Pipeline(prevents leakage); fit on train only,transformtest. - Use
stratify=yfor classification splits; setrandom_stateeverywhere for reproducibility. - Scale features for SVM/KNN/NN/PCA/regularized-linear/K-Means; tree models and Naive Bayes do not need it.
- Pick metrics for the problem: F1/accuracy on balanced data; precision/recall/ROC AUC/balanced accuracy on imbalanced data.
See references/best_practices_and_troubleshooting.md for code examples and fixes for ConvergenceWarning, overfitting, and large-dataset memory errors.
Additional Resources
- Official Documentation: https://scikit-learn.org/stable/
- User Guide: https://scikit-learn.org/stable/user_guide.html
- API Reference: https://scikit-learn.org/stable/api/index.html
- Examples Gallery: https://scikit-learn.org/stable/auto_examples/index.html
Files in this skill
12alterlab-scikit-learn skill questions
How do I install the alterlab-scikit-learn skill in Claude Code?
Run npx degit AlterLab-IEU/AlterLab-Academic-Skills/skills/data-science/alterlab-scikit-learn ~/.claude/skills/alterlab-scikit-learn. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the alterlab-scikit-learn skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
How do I install and run scikit-learn using uv?
You can run it without a manual install step by using: uv run --python ">=3.12" --with "scikit-learn>=1.8" --with pandas python script.py.
When should I use this skill instead of alterlab-pymc?
You should use alterlab-pymc if your task involves Bayesian models with posteriors, credible intervals, or MCMC diagnostics.
How can I prevent data leakage during preprocessing?
You can prevent data leakage by wrapping your preprocessing steps and estimator inside a scikit-learn Pipeline and fitting it only on the training data.