scikit-learn

Guides classification, regression, clustering, and pipeline construction with scikit-learn.

Updated Aug 15, 2026
One-click install
npx skills add https://github.com/qqlcx5/skills-hub --skill scikit-learn-qqlcx5
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: scikit-learn
Source: https://github.com/qqlcx5/skills-hub/tree/main/skills/scikit-learn
Command: npx skills add https://github.com/qqlcx5/skills-hub --skill scikit-learn-qqlcx5

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires scikit-learn.

What problem does it solve? Choosing the right algorithm, preprocessing steps, and evaluation strategy for classical machine learning tasks is error-prone, and mistakes like fitting scalers on full datasets cause data leakage and misleading results. ## Core Features & Use Cases - Algorithm Selection: Decision tables for classification, regression, clustering, and dimensionality reduction map algorithms like Random Forest, SVM, KMeans, and PCA to their best-fit scenarios. - Pipeline & Preprocessing Guidance: Explains Pipeline, ColumnTransformer, imputation, scaling, and encoding flows that prevent data leakage. - Evaluation & Tuning: Covers cross-validation strategies, task-appropriate metrics, and GridSearchCV versus RandomizedSearchCV trade-offs. - Use Case: When building a churn classifier on an imbalanced dataset, follow the guidance to use StratifiedKFold, F1-score instead of accuracy, and a pipeline that scales features only on training folds. ## Quick Start Ask the agent to build a scikit-learn pipeline that preprocesses numeric and categorical columns, trains a random forest classifier, and evaluates it with stratified cross-validation.

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 machine learning pipeline in scikit-learn?

Use sklearn's Pipeline to chain preprocessing steps like SimpleImputer and StandardScaler with an estimator such as RandomForestClassifier. Pipelines ensure transformations are fit only on training data, preventing data leakage during cross-validation.

Which scikit-learn algorithm should I use for classification?

Logistic regression works as a fast interpretable baseline, random forest handles non-linear relationships and provides feature importance, and gradient boosting typically gives the best accuracy on tabular data. SVM suits high-dimensional data with few samples.

GridSearchCV vs RandomizedSearchCV for hyperparameter tuning?

GridSearchCV exhaustively tests every parameter combination but is slow with many parameters. RandomizedSearchCV samples combinations and is faster, though it may miss the optimal point. HalvingGridSearchCV offers an efficient alternative in sklearn 0.24+.

Why is my scikit-learn model accuracy misleading on imbalanced data?

Accuracy is misleading when classes are imbalanced because predicting the majority class scores highly. Use F1-score, ROC-AUC, or balanced accuracy instead, and apply StratifiedKFold to preserve class distribution across folds.

When should I scale features before training in sklearn?

Distance-based and gradient-based algorithms like KNN, SVM, and PCA require scaled features using StandardScaler or MinMaxScaler. Tree-based models like random forest are scale-invariant. Always fit the scaler inside a pipeline on training data only.