skorch-dev/skorch
A PyTorch estimator adapter for scikit-learn pipelines and model selection
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & Core Mechanics
skorch is an in-process estimator adapter, not a model server. The caller supplies a PyTorch nn.Module; NeuralNetClassifier wraps its training and prediction lifecycle behind scikit-learn methods such as fit and predict_proba. A Pipeline can fit a StandardScaler before the network, and GridSearchCV can vary both estimator settings and module constructor arguments through names such as module__num_units.
The setuptools configuration packages skorch* and excludes notebooks and assets from package discovery. The declared runtime dependencies are NumPy, scikit-learn, SciPy, tabulate, and tqdm. PyTorch is installed separately for the target platform. The extension points shown are the user’s module, nested training settings such as iterator_train__shuffle, and training callbacks; there is no separate service to connect to.
Key Capabilities & Differentiators
The concrete classifier workflow accepts NumPy input, trains a user-defined network, and returns class probabilities. The same estimator can sit behind preprocessing or be tuned with cross-validation. Training features include learning-rate scheduling, scikit-learn and custom scoring, early stopping, checkpointing, parameter freezing and unfreezing, and progress reporting in terminals or notebooks.
Hugging Face and GPyTorch integrations extend interoperability, with GPyTorch covering Gaussian-process workflows. They do not establish support for any particular LLM family, serving protocol, or inference throughput. v1.4.0 adds scikit-learn metadata routing so supported workflows can pass information such as groups through Pipeline and GridSearchCV. It also extends tensor-to-NumPy conversion to more device types without specifying an exhaustive device matrix.
Trade-offs & Limitations
Choose skorch over a handwritten PyTorch loop when estimator compatibility is the main requirement: preprocessing, scoring, and parameter search can stay in scikit-learn. A direct loop is preferable when the training procedure must be controlled explicitly and the estimator interface adds little. If a native scikit-learn estimator already meets the modeling goal, it avoids the extra PyTorch runtime and model code.
Grid search still repeats training across candidates and folds. With an internal validation split enabled, each outer fit trains on less of its fold; disabling it, as the example does, means revisiting callbacks that need internal validation scores. Size the runtime around the network, batch size, optimizer state, and concurrent fits rather than the adapter itself. The project is in low-development mode: maintenance continues, but adoption should not depend on a steady stream of new features.
Hardware & Deployment Guide
For this checkout, use Python 3.11 or newer: pyproject.toml sets that floor even though the installation prose still mentions Python 3.9. Install the CPU or accelerator build of PyTorch appropriate for the host, then install skorch with pip or from the checkout. Training and prediction run in the application process without a hosted API. For reproducibility, pin and test the Python, PyTorch, and scikit-learn combination you deploy.
Treat the root Dockerfile as legacy rather than as a current deployment recipe. It starts from nvidia/cuda:9.0-cudnn7-runtime, installs Python 3.5 tooling, and copies a requirements.txt not listed in the supplied root tree. Build a fresh image if containerization is required. Recent releases address compatibility: v1.3.0 added the fitted-state protocol, v1.3.1 fixed the boolean result of __sklearn_is_fitted__ for scikit-learn 1.8 compatibility, and v1.4.0 added metadata routing and broader device conversion.
NeuralNetClassifier exposes fit and predict_proba for a PyTorch nn.Module.module__num_units alongside learning rate and epoch count, with the pipeline step prefix when applicable.NeuralNet a scikit-learn metadata router and consumer.pyproject.toml requires Python 3.11+ and leaves PyTorch installation separate.requirements.txt input is absent from the supplied root tree.Teams with an existing scikit-learn preprocessing and evaluation workflow that need to train and tune a custom PyTorch model within it.
You primarily need an LLM serving engine, require direct control over the training loop, or can meet the modeling goal with a native scikit-learn estimator.
Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| skorch ★ | 6.2k | +2 | Jupyter Notebook | BSD-3-Clause | A PyTorch estimator adapter for scikit-learn pipelines and model selection |
| fastai | 28.3k | +9 | Jupyter Notebook | Apache-2.0 | Layered PyTorch library for shorter training pipelines and custom training loops |
| llama-cookbook | 18.6k | +6 | Jupyter Notebook | MIT | Notebook-first SDK for Llama inference, fine-tuning, RAG, and API integration |
| annotated_deep_learning_paper_implementations | 67.8k | +43 | Python | MIT | Annotated PyTorch references for understanding and adapting deep learning algori |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/skorch-dev/skorch.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about skorch
How do I tune a PyTorch model and its preprocessing together?
nn.Module with NeuralNetClassifier and use it as the final step in a scikit-learn Pipeline. If that step is named net, a module parameter such as num_units can be tuned from GridSearchCV as net__module__num_units. Configure the outer CV splitter and skorch’s internal validation separately, especially if a callback needs validation metrics.Do I need a GPU, and how should I size memory for a search?
Can we use skorch commercially and run it on our own infrastructure?
When is direct PyTorch or a native scikit-learn estimator a better choice?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy