OpenViSTAI · Agents · Blockchain · Crypto
Menu
AI Developer Tools & SDKs

M2Cgen

M2Cgen is a Python library and command-line tool that transpiles supported trained statistical and machine-learning models into native source code in multiple programming languages. Its generated model code is described as dependency-free, allowing inference logic to be incorporated into applications without relying on a separate model-serving runtime.

Independent OpenViST project profile, based on linked sources.

M2Cgen — OpenViST project profile in AI Developer Tools & SDKs.
OpenViST project illustration. See the linked sources for product details.
Understand the project

Practical overview

When it fits

Use M2Cgen when a trained model is among the supported estimators and you want generated source code for integration into a target-language application. Review output semantics and tested package versions before relying on the generated function in an application.

Who it is for

  • Python practitioners exporting supported trained models into another programming language.
  • Application developers who want model inference logic as source code rather than a separate serving runtime.
  • Teams working in environments where adding runtime dependencies is difficult.

Documented uses

  • Convert a supported fitted estimator into native source code for a selected target language.
  • Generate code from a serialized model using the command-line interface.
  • Embed model inference logic in an application written in a supported language.
Before you choose

Requirements & limits

The repository advertises an MIT license. The README specifies Python 3.7 or later and gives pip as the installation route.

  • Model support is specific to estimator families and implementations; consult the README’s supported-model table.
  • Classification outputs differ by model family: decision scores for linear and SVM cases, and class probabilities for listed tree, forest and boosting classifiers.
  • The README identifies tested package versions through its CI requirements and says other versions are untested.
  • CLI use of serialized models depends on importable top-level model classes.
  • The README notes that ensemble generation may encounter Python recursion limits.

Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.

Source-based practical guide

Export a fitted scikit-learn model to Java

Generate Java source representing a fitted linear regression model using the documented Python interface.

Before you start

  • Python 3.7 or later
  • m2cgen installed with pip
  • A fitted scikit-learn LinearRegression estimator

Steps

  1. Import m2cgen and the scikit-learn model class in Python.

  2. Fit the LinearRegression estimator on training data.

  3. Call m2cgen.export_to_java(estimator) to generate Java code.

Expected outcome

A Java source string containing a model class with a score method, as shown in the project README.

Guide limitations

  • The example covers linear regression; support for other models and languages depends on the project’s supported-model and language lists.
Source-based practical guide

Generate code from a serialized model with the CLI

Use the m2cgen CLI to generate source code from a serialized model object.

Before you start

  • m2cgen installed
  • A model object serialized using Python’s pickle protocol
  • The model’s classes defined at the top level of an importable module in the unpickling environment

Steps

  1. Provide the serialized model file to the m2cgen command.

  2. Specify the output language with the --language option.

  3. Optionally set documented naming, indentation or recursion-limit options.

Expected outcome

Generated source code in the selected language.

Guide limitations

  • The README does not provide a complete model-training, serialization or deployment procedure.
  • Deserialization requires the model classes to be importable in the environment.
COMPARE OPTIONS

Compare options for Model inference and serving

These projects document a common task and share a project role. This is a source-based comparison, not an execution benchmark or a guarantee of interchangeability.

ProjectDocumented purposePlatformAccess and requirements
M2CgenConvert a supported fitted estimator into native source code for a selected target language.CLIThe repository advertises an MIT license. The README specifies Python 3.7 or later and gives pip as the installation route.
HyperposeCustomize pose-estimation architectures and datasets.Docker, Linux, macOS, Windows
Multi Task NlpDefine multiple tasks and their data and model settings in a YAML file.Linux, macOS, WindowsThe project is an open-source library under the Apache-2.0 license, distributed through its public GitHub repository.
Evidence and transparency

Sources & review

Source record details
Source availability
Active
Sources checked
14 October 2026
Original website title
BayesWitnesses/m2cgen · Official homepage title · retained in its source language