scikit-learn

Build classification, regression, and clustering pipelines with scikit-learn in Python.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill scikit-learn-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scikit-learn
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/scikit-learn
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill scikit-learn-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires scikit-learn, numpy, pandas, matplotlib, and includes scripts (resource) and references (resource) components.

What problem does it solve? It guides machine learning work in Python with scikit-learn, covering the full workflow from preprocessing raw data through training, tuning, and evaluating models without common pitfalls like data leakage. ## Core Features & Use Cases - Supervised and Unsupervised Learning: Reference documentation for classification, regression, clustering, and dimensionality reduction algorithms with selection guidance. - Pipelines and Preprocessing: Patterns for ColumnTransformer, scaling, encoding, and imputation that prevent data leakage in cross-validation. - Model Evaluation and Tuning: Cross-validation strategies, GridSearchCV and RandomizedSearchCV, and classification, regression, and clustering metrics. - Use Case: Given a CSV with mixed numeric and categorical columns, build a complete Pipeline with imputation, one-hot encoding, and a tuned RandomForestClassifier, then evaluate it with stratified cross-validation and a classification report. ## Quick Start Ask the AI to build a scikit-learn classification pipeline with preprocessing and hyperparameter tuning for your dataset.

Frequently Asked Questions about scikit-learn

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a scikit-learn pipeline with mixed numeric and categorical data?

Use ColumnTransformer to apply StandardScaler and SimpleImputer to numeric columns and OneHotEncoder to categorical columns, then wrap it in a Pipeline with your estimator. This prevents data leakage during cross-validation and keeps preprocessing consistent between training and prediction.

How to tune hyperparameters with GridSearchCV in scikit-learn?

Define a parameter grid using double-underscore notation for pipeline steps, then pass it to GridSearchCV with a cv value and scoring metric. Access the best configuration through best_params_ and the fitted model through best_estimator_.

Which scikit-learn algorithms require feature scaling?

SVM, KNN, neural networks, PCA, regularized linear models, and K-Means clustering require scaled features. Tree-based models like Random Forest and Gradient Boosting, plus Naive Bayes, work without scaling.

How do I evaluate a clustering model without ground truth labels?

Use silhouette score, Calinski-Harabasz index, or Davies-Bouldin score from sklearn.metrics. Higher silhouette and Calinski-Harabasz values indicate better clusters, while lower Davies-Bouldin values are preferable.

Why does my scikit-learn model perform well in training but poorly on test data?

This indicates overfitting or data leakage. Fit preprocessors only on training data, use stratified cross-validation, add regularization such as Ridge alpha, and verify you never call fit_transform on the full dataset before splitting.