Skip to main content

SKLX

Ruff Pytest image

A scikit-learn compatible neural network library that wraps MLX. Highly inspired by skorch.

Examples

import numpy as np
from sklearn.datasets import make_classification
from mlx import nn
from sklx import NeuralNetClassifier

X, y = make_classification(1000, 20, n_informative=10, random_state=0)
X = X.astype(np.float32)
y = y.astype(np.int64)

class MyModule(nn.Module):
    def __init__(self, num_units=10, nonlin=nn.ReLU()):
        super().__init__()

        self.dense0 = nn.Linear(20, num_units)
        self.nonlin = nonlin
        self.dropout = nn.Dropout(0.5)
        self.dense1 = nn.Linear(num_units, num_units)
        self.output = nn.Linear(num_units, 2)
        self.softmax = nn.Softmax(dim=-1)

    def forward(self, X, **kwargs):
        X = self.nonlin(self.dense0(X))
        X = self.dropout(X)
        X = self.nonlin(self.dense1(X))
        X = self.softmax(self.output(X))
        return X

net = NeuralNetClassifier(
    MyModule,
    max_epochs=10,
    lr=0.1,
)

net.fit(X, y)
y_proba = net.predict_proba(X)

In an sklearn Pipeline:

from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

pipe = Pipeline([
    ('scale', StandardScaler()),
    ('net', net),
])

pipe.fit(X, y)
y_proba = pipe.predict_proba(X)

With grid search:

from sklearn.model_selection import GridSearchCV

params = {
    'lr': [0.01, 0.02],
    'max_epochs': [10, 20],
    'module__num_units': [10, 20],
}
gs = GridSearchCV(net, params, refit=False, cv=3, scoring='accuracy', verbose=2)

gs.fit(X, y)
print("best score: {:.3f}, best params: {}".format(gs.best_score_, gs.best_params_))

Future Roadmap

  1. Completing Feature Parity with Skorch
    1. Pipeline Support
    2. Grid Search Support
    3. Learning Rate Scheduler https://github.com/lazarust/sklx/issues/6
    4. Scoring https://github.com/lazarust/sklx/issues/7
    5. Early Stopping https://github.com/lazarust/sklx/issues/8
    6. Checkpointing https://github.com/lazarust/sklx/issues/9
    7. Parameter Freezing https://github.com/lazarust/sklx/issues/10
    8. Progress Bar https://github.com/lazarust/sklx/issues/11

Metadata

Release files for sklx 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sklx 0.0.10
File Size Uploaded
sklx-0.0.10.tar.gz 233.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sklx 0.0.10
File Interpreter ABI Platform
sklx-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 240.6 kB

Release files / sklx-0.0.10.tar.gz

Download URL sklx-0.0.10.tar.gz
Size 233.1 kB
Tags Source
SHA-256 checksum
How to use checksums
344562b79d9ccff4f2ace38413ef832e9114f011c0544aa59165926561277bd0
BLAKE2b-256 checksum
How to use checksums
6aad28afc458987f995ce8d4b99883c181c7975c7701e31781f0a111e06da552
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release files / sklx-0.0.10-py3-none-any.whl

Download URL sklx-0.0.10-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afe88b87cd5e717e1c708077d49c661c5a5a21a8f30ab4a5a1da999a571a28b3
BLAKE2b-256 checksum
How to use checksums
2d165a3e162d1bedb28a8cccc760fd8639eda5adc216c7f7bb3fb5235b7a14e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

0.0.9

2 release files

0.0.6

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page