Scan your whole stack
Are you using mlx-learn?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.1.7
mlx-learn was last scanned on 23 Nov 2026 at version 0.1.7. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.1.7 LATEST | 23 Nov 2026 | No rules fired |
| 0.1.6 | 19 Nov 2026 | No rules fired |
| 0.1.5 | 19 Nov 2026 | No rules fired |
| 0.1.4 | 18 Nov 2026 | Not shown |
| 0.1.2 | 11 Nov 2026 | Not shown |
Findings for v0.1.7. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.1.7; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
Classical machine learning on Apple silicon, accelerated with MLX, with a scikit-learn compatible API.
mlxlearn is not officially associated with scikit-learn or PROBABL, nor with Apple.
mlxlearn has two layers.
Layer 1 — the library. Explicit imports, typed solver configuration and state, strict
errors, eager fit, no mutation of scikit-learn, no data-keyed caches:
from mlxlearn.neighbors import KNeighborsClassifier
clf = KNeighborsClassifier(n_neighbors=5).fit(X_train, y_train)
y_pred = clf.predict(X_test)
Layer 2 — the patching shell. A thin adapter that points scikit-learn's own names at Layer 1 estimators, so existing code — including code an LLM generated against the scikit-learn API — runs accelerated without being edited:
from mlxlearn import patch_sklearn
patch_sklearn()
from sklearn.svm import SVC # now resolves to the accelerated class
The numerical library is fully usable and fully tested with the patching mechanism absent.
Direct KNN classes use sklearn's public estimator interface without inheriting
its concrete neighbor classes, avoiding those imports during ordinary startup.
isinstance against a stock neighbor class is therefore false for direct KNN
objects. Use their own graph methods; sklearn's standalone graph helpers do not
accept these objects as fitted-estimator inputs. Patched KNN classes retain
stock inheritance. See the compatibility details.
0.1.7 — alpha. The API may change. See CHANGELOG.md.
| Estimator | Status |
|---|---|
mlxlearn.neighbors.NearestNeighbors |
0.1.0 |
mlxlearn.neighbors.KNeighborsClassifier |
0.1.0 |
mlxlearn.neighbors.KNeighborsRegressor |
0.1.0 |
mlxlearn.neighbors.RadiusNeighborsClassifier |
0.1.7 |
mlxlearn.neighbors.RadiusNeighborsRegressor |
0.1.7 |
mlxlearn.linear_model.LogisticRegression |
0.1.0 |
mlxlearn.linear_model.LinearRegression |
0.1.7, dense host solver with certified rank |
mlxlearn.svm.SVC (exact) |
0.1.0 |
mlxlearn.decomposition.PCA |
0.1.2 |
mlxlearn.cluster.EMeans |
0.1.3; Metal GPU, paper/Faiss recipes |
mlxlearn.cluster.KMeans |
0.1.3; Metal GPU, Lloyd clustering; Metal k-means++ seeding since 0.1.6 |
mlxlearn.cluster.OMeans |
0.1.5; Metal GPU, e-means with a two-level centroid search |
Ridge, DBSCAN, TSNE |
planned, 0.2.x |
SVR, NuSVR, NuSVC |
deferred — will not ship until they implement the true objective |
| tree ensembles | out of scope |
KMeans(init="k-means++") now
chooses its starting centers with a Metal screen, and for a given
random_state it selects the same rows as sklearn.cluster.kmeans_plusplus.
On MNIST (60,000 × 784, M4 Max) seeding 8,192 centers takes 5.4 s instead
of 217 s, and the default fit at 1,024 to 8,192 centers takes 1.4–7.0 s
instead of 27–219 s, with the same iterations and inertia.
K-means++ initializationOMeans
reached EMeans' held-out error 4.44× faster in float32 and 3.55× in
BF16 on an M5 Ultra, and 4.13× and 3.96× on an M4 Max, as geometric
means. At ten million rows and 65,536 centroids it was 8.8× faster in
float32 on the M5 Ultra. It compares each row with a median 11% of the
centroids, and its held-out error at the same epochs stays within −1.14%
to +0.36% of EMeans'.
M5 Ultra report ·
M4 Max reportOMeans fit at 4,096 to 8,192 centroids takes 150–242 ms on an M4 Max,
against 107–223 s for scikit-learn's KMeans, with held-out error within
1% of it. Against EMeans this small data gains 1.4× in training at 4,096
centroids and 2.0–2.3× at 8,192.
MNIST-family resultscache_size. At 200 MiB
on M4 Max, standard MNIST fit time fell from 9.09 to 3.59 s (2.53×) and
Fashion-MNIST from 10.29 to 4.59 s (2.24×) against the previous solver.
On standard MNIST, accuracy was 97.92% and all 450,000 decision scores
matched the previous build. Full SVC benchmarkVersion 0.1.3 includes e-means, with Metal assignment and update kernels for Apple Silicon:
from mlxlearn.cluster import EMeans
model = EMeans(n_clusters=4096, max_iter=3, random_state=10).fit(X_train)
labels = model.predict(X_test)
It supports the published recipe, a separately specified Faiss recipe,
last-epoch means, slow EMA, and spherical clustering. See the
implementation guide and reproducible paper-data benchmarks.
Measured results are in the M4 Max benchmark report.
The direct Faiss e-means comparison
measures runtime, process memory, and held-out quality with matched Faiss recipes.
precision="bfloat16" enables native BF16 Metal assignment with float32
accumulation and state, plus the Faiss BF16 statistics semantics. The
optimization and H100 protocol report
compares it with a matched Metal GEMM baseline and documents the limits of
comparison with published H100 times.
The subsequent hardware-gap investigation
separates arithmetic throughput from implementation overhead and compares further
optimizations against a frozen native-BF16 implementation in fresh paired runs.
The five-dataset 10M-vector comparison
measures matched FP32 Metal and original Faiss CPU runs: Metal is 3.98–18.95×
faster, with test-MSE differences within 0.061% in this single-seed campaign.
EMeans is an explicit estimator; it does not replace sklearn's KMeans through patching.
For full-batch Lloyd clustering, Metal KMeans is available
through from mlxlearn.cluster import KMeans. It supports dense FP32 training,
explicit, random or k-means++ initialization, multiple restarts, and final
nearest-centroid labels and inertia. Use the direct estimator; it is not part
of patch_sklearn(). Since 0.1.6 its k-means++ initialization runs on the
GPU and selects the same centers as scikit-learn's helper for a given
random_state; see K-means++ initialization.
The 0.1.3 equal-pass comparison reports runtime, peak fit memory, and test MSE for four methods on five 10M-vector datasets.
Version 0.1.5 adds OMeans for clustering with many
centroids. During two-level training, each row is compared with the
centroids of a few nearby coarse cells, covering 6–25% of the centroids on
the measured embedding datasets. The estimator follows the
o-means post with separate Metal kernels.
from mlxlearn.cluster import OMeans
model = OMeans(n_clusters=16384, max_iter=2, random_state=10).fit(X_train)
Against EMeans(recipe="faiss") with the same batch law, seed and starting
centroids, over 18 datasets and three seeds. Each entry is a geometric mean of
e-means' fit time divided by o-means'.
| M5 Ultra, float32 | M5 Ultra, BF16 | M4 Max, float32 | M4 Max, BF16 | |
|---|---|---|---|---|
Time to EMeans' held-out error |
4.44× | 3.55× | 4.13× | 3.96× |
| Same epochs | 4.44× | 3.42× | 4.20× | 3.90× |
Time to EMeans' error, 10M rows and 65,536 centroids |
8.8× | 5.9× | 7.3× | 7.0× |
EMeans' at one epoch and −0.17% to +0.36% at two. O-means needs 2 to 2.5
epochs to match EMeans' two-epoch error.assignment="auto"
can select the two-level search from 4,224 centroids, or from 2,176
with 512 features or more. On M1 Ultra and M5 Ultra, fits shorter than two
epochs keep the full search from 2,176 to 4,223 centroids at 512 features or
more, where one-epoch fits on M5 Ultra were measured slower than EMeans.
It returns to the full search when a fit's cells turn out too uneven to
save comparisons. Final labels, predict and score always use a full
search.See the implementation guide and the benchmark reports for M5 Ultra and M4 Max. Results on the much smaller MNIST family are below.
Python 3.10 is supported with scikit-learn 1.7.x; scikit-learn 1.8+ requires Python ≥ 3.11.
CI tests only valid pairs — see docs/support_matrix.md.
pip install mlx-learn
Version 0.1.7 provides Apple silicon wheels for Python 3.10–3.13 with Metal
and C++ CPU extensions. Source builds can also include these optional extensions.
The KNN CPU extension handles small workloads and is compiled at build time;
fitting or querying never invokes the C++ compiler. A compatible wheel includes
the extensions built into it.
Without a compiler or CPU extension, the certified portable CPU implementation
remains available with the same ordering contract; native-build benchmark timings
do not describe that fallback's performance.
The CPU module uses the full CPython C API, so wheels containing it target a
specific Python minor version. The Metal component itself retains its stable
abi3 interface. Installing a compatible prebuilt wheel needs no compiler.
Patching replaces attributes on scikit-learn modules. Attribute access
(sklearn.svm.SVC) therefore resolves to the mlxlearn class whether import sklearn
happened before or after patch_sklearn().
Symbols captured before patching are local bindings and cannot be rebound:
from sklearn.svm import SVC # binds the stock class into your namespace
patch_sklearn() # cannot reach back and change SVC
SVC() # still the stock class
That is Python name binding, not a bug in mlxlearn. The supported pattern is patch-first.
patch_sklearn() is idempotent, and unpatch_sklearn() fully restores scikit-learn.
Layer 1 raises a precise error when it cannot honor a request. Layer 2 falls back to stock scikit-learn instead — but only for capability mismatches (sparse input, an unsupported parameter, an unsupported dtype), never to hide a bug:
| Situation | Direct import | Patched |
|---|---|---|
| Capability mismatch | precise MLXLearnError |
falls back, warns once per class, records diagnostics |
KNN with device="auto" |
owned CPU/GPU search | owned CPU/GPU search |
| Other estimators below the measured crossover | internal CPU path | dispatches to scikit-learn |
| Invalid user input | sklearn-equivalent validation error | scikit-learn's own exception, unmasked |
| Unexpected backend runtime failure | raises | raises — never silently rerun on scikit-learn |
Set the policy with fallback_policy="warn" | "raise" | "silent". Diagnostics are recorded
in every mode:
import mlxlearn
with mlxlearn.config_context(fallback_policy="raise"):
... # any capability fallback becomes an error
mlxlearn.get_last_backend_event() # what the last fit/predict actually did
mlxlearn.get_backend_diagnostics() # everything recorded this session
Sticky fitted policy. execution_backend_ records the fit backend ("mlx",
"cpu", or "sklearn"). Inference reuses that backend, except for NumPy KNN
estimators fitted with device="auto": their execution_policy_ is "auto",
allowing each query batch to use the owned CPU or GPU search. Small datasets and
single queries can avoid GPU launch overhead, while larger batches retain the GPU
path. last_query_backend_ and backend diagnostics report the actual search.
Explicit KNN device choices use a "fixed" policy. Changing global configuration
after fit does not alter either fitted policy, and automatic CPU search does not
invoke a scikit-learn solver. A new fit clears state and may choose differently.
PCA records the fit backend and selects CPU or GPU projection per batch according
to input size and precision.
The public surface is deliberately small:
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.