← all repositories
nok/sklearn-porter

Take your scikit-learn model to C, Java, or JS — no runtime required

A transpiler that turns trained estimators into standalone code for embedded systems and performance-critical deployments.

sklearn-porter
Velocity · 7d
+0.4
★ / day
Trend
steady
star history

What it does

sklearn-porter converts trained scikit-learn estimators into source code in C, Java, JavaScript, Go, PHP, or Ruby. The output runs without Python or scikit-learn installed — useful when you need to drop a decision tree onto a microcontroller or ship an SVM inside a mobile app.

The interesting bit

The project doesn’t just dump coefficients; it generates actual executable logic (if-else chains for trees, kernel computations for SVMs) and offers three template modes: attached data, exported JSON, or combined. It even includes an integrity-check test() that verifies the ported version matches Python’s output.

Key highlights

  • Supports 10 estimator families including SVMs, random forests, neural nets, and naive Bayes
  • Coverage varies sharply by language: decision trees work everywhere; MLPRegressor only emits JavaScript
  • CLI, functional, and OOP APIs all available
  • Development branch targets v1.0.0; stable release is v0.7.4
  • Requires scikit-learn between 0.17 and 0.22 — notably behind current releases

Caveats

  • Scikit-learn version ceiling of 0.22 means many modern projects won’t be compatible
  • Support matrix has significant gaps: no C or Go for random forests, no Java for AdaBoost, etc.
  • README warns to “always” run the integrity check, suggesting edge cases exist

Verdict

Worth a look if you’re maintaining legacy scikit-learn pipelines and need to deploy to constrained environments. Skip it if you’re on modern scikit-learn or need broad language coverage for newer estimators.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.