m2cgen

m2cgen

★ 3.8 🔖 1200 saves 💰 Free GitHub

m2cgen (Model 2 Code Generator) is an open-source tool that converts trained machine learning models into native, dependency-free code in a wide range of programming languages. Train a model in Python as usual, and m2cgen emits an equivalent implementation in Java, C, Go, JavaScript, C#, Rust and many other languages, so the model can run anywhere — including environments where installing a Python ML stack is impossible. The project has around 3,000 stars on GitHub.

Overview

Deploying a scikit-learn or XGBoost model usually drags along the whole training framework, which is a problem for embedded systems, mobile apps, legacy enterprise stacks and latency-sensitive services. m2cgen sidesteps this by translating the learned model itself — the trees, coefficients and support vectors — into plain source code with zero external dependencies. The generated code is readable and self-contained, so it can be audited, compiled and shipped like any other part of your codebase. It supports a broad set of estimators, from linear models and random forests to gradient boosting libraries such as XGBoost and LightGBM.

Key Features

  • Exports trained ML models as native code with zero runtime dependencies
  • Target languages include Java, C, C#, Go, JavaScript, Python, Rust, R, PHP, Dart, Haskell, Ruby, F# and more
  • Supports scikit-learn models plus XGBoost, LightGBM and statsmodels estimators
  • Covers classifiers, regressors and clustering models
  • Generated code is human-readable and easy to audit or embed
  • Ideal for edge, embedded and legacy environments without a Python runtime

💳 Pricing

m2cgen is completely free and open source under the MIT license. There is no commercial version, hosted service or paid support tier required to use it.

Who Is It For

m2cgen is for data scientists and engineers who need to ship classical ML models into production systems written in other languages, or onto constrained hardware where a full ML runtime is not an option.

🚀 Visit m2cgen Official Site

🚩 Report an issue