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
uv uv pip install scikit-learn
uv uv pip install matplotlib seaborn
uv uv pip install pandas numpy
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
Quick Start
Classification Example
from sklearn. model_selection import train_test_split
from sklearn. preprocessing import StandardScaler
from sklearn. ensemble import RandomForestClassifier
from sklearn. metrics import classification_report
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size= 0.2 , stratify= y, random_state= 42
)
scaler = StandardScaler( )
X_train_scaled = scaler. fit_transform( X_train)
X_test_scaled = scaler. transform( X_test)
model = RandomForestClassifier( n_estimators= 100 , random_state= 42 )
model. fit( X_train_scaled, y_train)
y_pred = model. predict( X_test_scaled)
print ( classification_report( y_test, y_pred) )
Complete Pipeline with Mixed Data
from sklearn. pipeline import Pipeline
from sklearn. compose import ColumnTransformer
from sklearn. preprocessing import StandardScaler, OneHotEncoder
from sklearn. impute import SimpleImputer
from sklearn. ensemble import GradientBoostingClassifier
numeric_features = [ 'age' , 'income' ]
categorical_features = [ 'gender' , 'occupation' ]
numeric_transformer = Pipeline( [
( 'imputer' , SimpleImputer( strategy= 'median' ) ) ,
( 'scaler' , StandardScaler( ) )
] )
categorical_transformer = Pipeline( [
( 'imputer' , SimpleImputer( strategy= 'most_frequent' ) ) ,
( 'onehot' , OneHotEncoder( handle_unknown= 'ignore' ) )
] )
preprocessor = ColumnTransformer( [
( 'num' , numeric_transformer, numeric_features) ,
( 'cat' , categorical_transformer, categorical_features)
] )
model = Pipeline( [
( 'preprocessor' , preprocessor) ,
( 'classifier' , GradientBoostingClassifier( random_state= 42 ) )
] )
model. fit( X_train, y_train)
y_pred = model. predict( X_test)
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 (target encoding)
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
Classification Pipeline
Run a complete classification workflow with preprocessing, model comparison, hyperparameter tuning, and evaluation:
python scripts/classification_pipeline.py
This script demonstrates:
Handling mixed data types (numeric and categorical)
Model comparison using cross-validation
Hyperparameter tuning with GridSearchCV
Comprehensive evaluation with multiple metrics
Feature importance analysis
Clustering Analysis
Perform clustering analysis with algorithm comparison and visualization:
python scripts/clustering_analysis.py
This script demonstrates:
Finding optimal number of clusters (elbow method, silhouette analysis)
Comparing multiple clustering algorithms (K-Means, DBSCAN, Agglomerative, Gaussian Mixture)
Evaluating clustering quality without ground truth
Visualizing results with PCA projection
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
Common Workflows
Building a Classification Model
Load and explore data
import pandas as pd
df = pd. read_csv( 'data.csv' )
X = df. drop( 'target' , axis= 1 )
y = df[ 'target' ]
Split data with stratification
from sklearn. model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size= 0.2 , stratify= y, random_state= 42
)
Create preprocessing pipeline
β
Make data-driven prioritization decisions faster
Stakeholder Communication Draft PRDs, status updates, and stakeholder presentations
Example
Create executive summary of Q3 roadmap, monthly progress report, feature launch announcement
β Save 3-5 hours/week on communication overhead
Implementation Guide Prerequisites
βΊ Claude Desktop or compatible AI client βΊ Access to product documentation and roadmap tools (Jira, Notion, etc.) βΊ Understanding of product management frameworks (RICE, Jobs-to-be-Done, etc.) βΊ Stakeholder contact information and communication channels Time Estimate
30-60 minutes to see productivity improvements
Steps
1 Install product management skill 2 Start with user story generation for known feature 3 Progress to competitive analysis: research 2-3 competitors 4 Use for roadmap prioritization: apply RICE/ICE scoring 5 Draft stakeholder communications and refine based on feedback 6 Build template library for recurring PM tasks 7 Share effective prompts with product team Common Pitfalls
β Not validating competitive researchβverify facts before sharing β Accepting user stories without involving engineering team β Over-relying on frameworks without qualitative judgment β Not customizing outputs to company culture and communication style β Skipping stakeholder validation of generated requirements Best Practices β Do
+ Validate research and competitive analysis with real data + Collaborate with engineering when generating technical requirements + Customize frameworks and templates to your company context + Use skill for first drafts, refine with stakeholder input + Document successful prompt patterns for PM tasks + Combine AI efficiency with human judgment and intuition β Don't
β Don't publish competitive analysis without fact-checking β Don't finalize user stories without engineering review β Don't make prioritization decisions solely on AI scoring β Don't skip customer validation of generated requirements β Don't ignore company-specific context and culture π‘ Pro Tips
β
Provide context: company goals, constraints, customer feedback β
Ask for alternatives: 'Show 3 ways to prioritize this roadmap' β
Request stakeholder-specific formatting: 'Executive summary vs. engineering spec' β
Use skill for 70% generation + 30% customization to company needs When to Use This β Use when
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
β Avoid when
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path 1 Basic: user stories, feature specs, status updates 2 Intermediate: competitive analysis, prioritization frameworks, PRDs 3 Advanced: product strategy, go-to-market planning, OKR setting 4 Expert: product vision, market positioning, business model innovation Reviews 4.5 β
β
β
β
β
45 reviews
A
Arya Tandon β
β
β
β
β
Dec 28, 2024
We added scikit-learn from the explainx registry; install was straightforward and the SKILL.md answered most questions upfront.
D
Dev Martin β
β
β
β
β
Dec 16, 2024
Keeps context tight: scikit-learn is the kind of skill you can hand to a new teammate without a long onboarding doc.
H
Hana Khan β
β
β
β
β
Dec 16, 2024
scikit-learn is among the better-maintained entries we tried; worth keeping pinned for repeat workflows.
H
Hana Nasser β
β
β
β
β
Dec 12, 2024
Solid pick for teams standardizing on skills: scikit-learn is focused, and the summary matches what you get after install.
C
Chaitanya Patil β
β
β
β
β
Dec 4, 2024
scikit-learn has been reliable in day-to-day use. Documentation quality is above average for community skills.
P
Piyush G β
β
β
β
β
Nov 23, 2024
Keeps context tight: scikit-learn is the kind of skill you can hand to a new teammate without a long onboarding doc.
A
Anika Abbas β
β
β
β
β
Nov 23, 2024
I recommend scikit-learn for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.
A
Ama Lopez β
β
β
β
β
Nov 19, 2024
scikit-learn fits our agent workflows well β practical, well scoped, and easy to wire into existing repos.
R
Rahul Santra β
β
β
β
β
Nov 15, 2024
Solid pick for teams standardizing on skills: scikit-learn is focused, and the summary matches what you get after install.
H
Hana Jackson β
β
β
β
β
Nov 7, 2024
scikit-learn has been reliable in day-to-day use. Documentation quality is above average for community skills.
showing 1-10 of 45
prev 1 / 5 next
Discussion Comments β not star reviews No comments yet β start the thread.