Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

scikit-learn

БесплатноЗапускает вложенные скриптыНе проверен

ML toolkit. Classification, regression, clustering, PCA, preprocessing, pipelines, GridSearch, cross-validation, RandomForest, SVM, for general machine…

lifangdaот lifangda★ 43 звезды на GitHub

Об этом скилле

Scikit-learn: Machine Learning in Python

Overview

Scikit-learn is Python's premier machine learning library, offering simple and efficient tools for predictive data analysis. Apply this skill for classification, regression, clustering, dimensionality reduction, model selection, preprocessing, and hyperparameter optimization.

When to Use This Skill

This skill should be used when:

  • Building classification models (spam detection, image recognition, medical diagnosis)
  • Creating regression models (price prediction, forecasting, trend analysis)
  • Performing clustering analysis (customer segmentation, pattern discovery)
  • Reducing dimensionality (PCA, t-SNE for visualization)
  • Preprocessing data (scaling, encoding, imputation)
  • Evaluating model performance (cross-validation, metrics)
  • Tuning hyperparameters (grid search, random search)
  • Creating machine learning pipelines
  • Detecting anomalies or outliers
  • Implementing ensemble methods

Core Machine Learning Workflow

Standard ML Pipeline

Follow this general workflow for supervised learning tasks:

  1. Data Preparation

    • Load and explore data
    • Split into train/test sets
    • Handle missing values
    • Encode categorical features
    • Scale/normalize features
  2. Model Selection

    • Start with baseline model
    • Try more complex models
    • Use domain knowledge to guide selection
  3. Model Training

    • Fit model on training data
    • Use pipelines to prevent data leakage
    • Apply cross-validation
  4. Model Evaluation

    • Evaluate on test set
    • Use appropriate metrics
    • Analyze errors
  5. Model Optimization

    • Tune hyperparameters
    • Feature engineering
    • Ensemble methods
  6. Deployment

    • Save model using joblib
    • Create prediction pipeline
    • Monitor performance

Classification Quick Start

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report
from sklearn.pipeline import Pipeline

# Create pipeline (prevents data leakage)
pipeline = Pipeline([
    ('scaler', StandardScaler()),
    ('classifier', RandomForestClassifier(n_estimators=100, random_state=42))
])

# Split data (use stratify for imbalanced classes)
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42, stratify=y
)

# Train
pipeline.fit(X_train, y_train)

# Evaluate
y_pred = pipeline.predict(X_test)
print(classification_report(y_test, y_pred))

# Cross-validation for robust evaluation
from sklearn.model_selection import cross_val_score
scores = cross_val_score(pipeline, X_train, y_train, cv=5)
print(f"CV Accuracy: {scores.mean():.3f} (+/- {scores.std():.3f})")

Regression Quick Start

from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_squared_error, r2_score
from sklearn.pipeline import Pipeline

# Create pipeline
pipeline = Pipeline([
    ('scaler', StandardScaler()),
    ('regressor', RandomForestRegressor(n_estimators=100, random_state=42))
])

# Split data
X_train, X_test, y_train, y_test = train_test_split(
    X, y, test_size=0.2, random_state=42
)

# Train
pipeline.fit(X_train, y_train)

# Evaluate
y_pred = pipeline.predict(X_test)
rmse = mean_squared_error(y_test, y_pred, squared=False)
r2 = r2_score(y_test, y_pred)
print(f"RMSE: {rmse:.3f}, R²: {r2:.3f}")

Algorithm Selection Guide

Classification Algorithms

Start with baseline: LogisticRegression

  • Fast, interpretable, works well for linearly separable data
  • Good for high-dimensional data (text classification)

General-purpose: RandomForestClassifier

  • Handles non-linear relationships
  • Robust to outliers
  • Provides feature importance
  • Good default choice

Best performance: HistGradientBoostingClassifier

  • State-of-the-art for tabular data
  • Fast on large datasets (>10K samples)
  • Often wins Kaggle competitions

Special cases:

  • Small datasets (<1K): SVC with RBF kernel
  • Very large datasets (>100K): SGDClassifier or LinearSVC
  • Interpretability critical: LogisticRegression or DecisionTreeClassifier
  • Probabilistic predictions: GaussianNB or calibrated models
  • Text classification: LogisticRegression with TfidfVectorizer

Regression Algorithms

Start with baseline: LinearRegression or Ridge

  • Fast, interpretable
  • Works well when relationships are linear

General-purpose: RandomForestRegressor

  • Handles non-linear relationships
  • Robust to outliers
  • Good default choice

Best performance: HistGradientBoostingRegressor

  • State-of-the-art for tabular data
  • Fast on large datasets

Special cases:

  • Regularization needed: Ridge (L2) or Lasso (L1 + feature selection)
  • Very large datasets: SGDRegressor
  • Outliers present: HuberRegressor
Полный SKILL.md на GitHub

Установить scikit-learn в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/model_evaluation.mdreferences/pipelines_and_composition.mdreferences/preprocessing.mdreferences/quick_reference.mdreferences/supervised_learning.mdreferences/unsupervised_learning.mdscripts/classification_pipeline.pyscripts/clustering_analysis.py

FAQ

Что делает скилл scikit-learn?

ML toolkit. Classification, regression, clustering, PCA, preprocessing, pipelines, GridSearch, cross-validation, RandomForest, SVM, for general machine learning workflows.

Как установить скилл scikit-learn?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл scikit-learn запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить scikit-learn с