Alterlab scikit learn

From AlterLab-IEU/AlterLab-Academic-Skills · View interactive version

Alterlab scikit learn is an AI agent skill from the GitHub repository AlterLab-IEU/AlterLab-Academic-Skills. Classical machine learning in Python with scikit-learn — algorithms, preprocessing, pipelines, and best-practice reference documentation. Use when working with supervised learning (classification, regression), unsupervised learning (clustering, dimensionality reduction), model evaluation, hyperparam

How to use this skill

Skill file

Scikit-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:

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:

When to use:

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:

Dimensionality reduction:

When to use:

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:

Hyperparameter tuning:

Metrics:

When to use:

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:

Encoding categorical variables:

Handling missing values:

Feature engineering:

When to use:

See: references/preprocessing.md for detailed preprocessing techniques.

5. Pipelines and Composition

Build reproducible, production-ready ML workflows.

Key components:

Benefits:

When to use:

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

Supervised Learning

File: references/supervised_learning.md

Unsupervised Learning

File: references/unsupervised_learning.md

Model Evaluation

File: references/model_evaluation.md

Preprocessing

File: references/preprocessing.md

Pipelines and Composition

File: references/pipelines_and_composition.md

Worked Examples

File: references/worked_examples.md

Best Practices & Troubleshooting

File: references/best_practices_and_troubleshooting.md

Common Workflows

See references/worked_examples.md for the numbered, copy-paste version of each workflow.

Version notes (scikit-learn 1.8–1.9)

Best Practices (essentials)

See references/best_practices_and_troubleshooting.md for code examples and fixes for ConvergenceWarning, overfitting, and large-dataset memory errors.

Additional Resources

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.