scikit-learn-ml

Machine learning with scikit-learn. Use when: classification, regression, clustering, dimensionality reduction, model evaluation, feature engineering. NOT for: deep learning (use transformers/pytorch), time series forecasting (use statsmodels), big data (use spark).

564 stars

Best use case

scikit-learn-ml is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Machine learning with scikit-learn. Use when: classification, regression, clustering, dimensionality reduction, model evaluation, feature engineering. NOT for: deep learning (use transformers/pytorch), time series forecasting (use statsmodels), big data (use spark).

Teams using scikit-learn-ml should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/scikit-learn-ml/SKILL.md --create-dirs "https://raw.githubusercontent.com/beita6969/ScienceClaw/main/skills/scikit-learn-ml/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/scikit-learn-ml/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How scikit-learn-ml Compares

Feature / Agentscikit-learn-mlStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Machine learning with scikit-learn. Use when: classification, regression, clustering, dimensionality reduction, model evaluation, feature engineering. NOT for: deep learning (use transformers/pytorch), time series forecasting (use statsmodels), big data (use spark).

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Scikit-Learn Machine Learning

Classification, regression, clustering, dimensionality reduction, and model evaluation.

## When to Use / When NOT to Use

**Use when:** classification, regression, clustering, dimensionality reduction, model evaluation, feature engineering, hyperparameter tuning, pipeline construction.

**NOT for:** deep learning (use transformers/pytorch), time series forecasting (use statsmodels), big data that doesn't fit in memory (use spark), GPU-accelerated training.

## Data Preparation and Splitting

```python
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.preprocessing import StandardScaler, MinMaxScaler, LabelEncoder

df = pd.read_csv('data.csv')
X = df.drop(columns=['target'])
y = df['target']

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42, stratify=y)

scaler = StandardScaler()                      # zero mean, unit variance
X_train_scaled = scaler.fit_transform(X_train) # fit on train only
X_test_scaled = scaler.transform(X_test)       # transform test with train stats

le = LabelEncoder()
y_encoded = le.fit_transform(y)                # string labels to integers
```

## Classification

```python
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.svm import SVC
from sklearn.metrics import classification_report, confusion_matrix, roc_auc_score

clf = RandomForestClassifier(n_estimators=100, random_state=42)
clf.fit(X_train_scaled, y_train)
y_pred = clf.predict(X_test_scaled)

print(classification_report(y_test, y_pred))
print(confusion_matrix(y_test, y_pred))
y_proba = clf.predict_proba(X_test_scaled)[:, 1]
print(f"ROC AUC: {roc_auc_score(y_test, y_proba):.4f}")

# Alternatives
gb = GradientBoostingClassifier(n_estimators=200, learning_rate=0.1)
svc = SVC(kernel='rbf', probability=True)
```

## Regression

```python
from sklearn.linear_model import LinearRegression, Ridge, Lasso, ElasticNet
from sklearn.metrics import mean_squared_error, r2_score

reg = Ridge(alpha=1.0)
reg.fit(X_train_scaled, y_train)
y_pred = reg.predict(X_test_scaled)
print(f"RMSE: {np.sqrt(mean_squared_error(y_test, y_pred)):.4f}")
print(f"R2:   {r2_score(y_test, y_pred):.4f}")

# ElasticNet combines L1+L2: ElasticNet(alpha=1.0, l1_ratio=0.5)
```

## Clustering

```python
from sklearn.cluster import KMeans, DBSCAN, AgglomerativeClustering
from sklearn.metrics import silhouette_score

km = KMeans(n_clusters=3, random_state=42, n_init=10)
labels = km.fit_predict(X_scaled)
print(f"Silhouette: {silhouette_score(X_scaled, labels):.4f}")

db = DBSCAN(eps=0.5, min_samples=5)           # density-based, no k needed
agg = AgglomerativeClustering(n_clusters=3)    # hierarchical
```

## Dimensionality Reduction

```python
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE

pca = PCA(n_components=2)
X_pca = pca.fit_transform(X_scaled)
print(f"Explained variance: {pca.explained_variance_ratio_.sum():.2%}")

tsne = TSNE(n_components=2, perplexity=30, random_state=42)
X_tsne = tsne.fit_transform(X_scaled)         # for visualization only
```

## Hyperparameter Tuning

```python
from sklearn.model_selection import GridSearchCV

param_grid = {'n_estimators': [100, 200], 'max_depth': [5, 10, None]}
grid = GridSearchCV(RandomForestClassifier(random_state=42),
                    param_grid, cv=5, scoring='f1_weighted', n_jobs=-1)
grid.fit(X_train_scaled, y_train)
print(f"Best params: {grid.best_params_}")
print(f"Best score:  {grid.best_score_:.4f}")

# Cross-validation shortcut
scores = cross_val_score(clf, X_train_scaled, y_train, cv=5, scoring='accuracy')
print(f"CV Accuracy: {scores.mean():.4f} +/- {scores.std():.4f}")
```

## Best Practices

1. Always split data before any preprocessing; fit scalers on train set only.
2. Use `stratify=y` in `train_test_split` for imbalanced classification.
3. Set `random_state` for reproducibility in models, splits, and clustering.
4. Use `cross_val_score` or `GridSearchCV` instead of single train/test evaluation.
5. Check `feature_importances_` (tree models) or `coef_` (linear) for interpretability.
6. Use `n_jobs=-1` to parallelize grid search and ensemble models.
7. For high-dimensional sparse data, prefer `LinearSVC` or `SGDClassifier` over kernel SVM.

Related Skills

scikit-survival

564
from beita6969/ScienceClaw

Comprehensive toolkit for survival analysis and time-to-event modeling in Python using scikit-survival. Use this skill when working with censored survival data, performing time-to-event analysis, fitting Cox models, Random Survival Forests, Gradient Boosting models, or Survival SVMs, evaluating survival predictions with concordance index or Brier score, handling competing risks, or implementing any survival analysis workflow with the scikit-survival library.

scikit-learn

564
from beita6969/ScienceClaw

Machine learning in Python with scikit-learn. Use when working with supervised learning (classification, regression), unsupervised learning (clustering, dimensionality reduction), model evaluation, hyperparameter tuning, preprocessing, or building ML pipelines. Provides comprehensive reference documentation for algorithms, preprocessing techniques, pipelines, and best practices.

scikit-bio

564
from beita6969/ScienceClaw

Biological data toolkit. Sequence analysis, alignments, phylogenetic trees, diversity metrics (alpha/beta, UniFrac), ordination (PCoA), PERMANOVA, FASTA/Newick I/O, for microbiome analysis.

xurl

564
from beita6969/ScienceClaw

A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.

xlsx

564
from beita6969/ScienceClaw

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

writing

564
from beita6969/ScienceClaw

No description provided.

world-bank-data

564
from beita6969/ScienceClaw

World Bank Open Data API for development indicators. Use when: user asks about GDP, population, poverty, health, or education statistics by country. NOT for: real-time financial data or stock prices.

wikipedia-search

564
from beita6969/ScienceClaw

Search and fetch structured content from Wikipedia using the MediaWiki API for reliable, encyclopedic information

wikidata-knowledge

564
from beita6969/ScienceClaw

Query Wikidata for structured knowledge using SPARQL and entity search. Use when: (1) finding structured facts about entities (people, places, organizations), (2) querying relationships between entities, (3) cross-referencing external identifiers (Wikipedia, VIAF, GND, ORCID), (4) building knowledge graphs from linked data. NOT for: full-text article content (use Wikipedia API), scientific literature (use semantic-scholar), geospatial data (use OpenStreetMap).

weather

564
from beita6969/ScienceClaw

Get current weather and forecasts via wttr.in or Open-Meteo. Use when: user asks about weather, temperature, or forecasts for any location. NOT for: historical weather data, severe weather alerts, or detailed meteorological analysis. No API key needed.

wacli

564
from beita6969/ScienceClaw

Send WhatsApp messages to other people or search/sync WhatsApp history via the wacli CLI (not for normal user chats).

voice-call

564
from beita6969/ScienceClaw

Start voice calls via the OpenClaw voice-call plugin.