name: m2cgen
description: "Use m2cgen to transpile fitted Python machine-learning models into
standalone C, C#, Dart, Elixir, F#, Go, Haskell, Java, JavaScript, PHP,
PowerShell, Python, R, Ruby, Rust, or Visual Basic code through its API or
CLI."
disable-model-invocation: true
metadata:
disco-role: operating
license: MIT
m2cgen
Use this repo skill when a task involves converting an already fitted Python estimator or booster into native source code, selecting a supported target language, or diagnosing m2cgen API/CLI export failures.
Install and verify
Install the public package in the environment that contains the fitted model:
python -m pip install m2cgen
python -c "import m2cgen; print(m2cgen.__version__)"
The package has a base NumPy dependency. The library that created a serialized model (for example scikit-learn, statsmodels, lightning, XGBoost, or LightGBM) must also be installed when the model is fitted or unpickled.
Route by task
Minimal decision process
- Confirm that the object is fitted and identify its runtime estimator class.
- Select one of the 16 supported target-language exporters; do not infer support from a similar language name.
- Use the Python API for an in-memory object or the CLI for pickle/joblib and shell pipelines.
- Pass only target-appropriate naming options, then validate the generated source before integrating it into a build.
- Compare generated predictions with the original model using the correct output semantics and a floating-point tolerance.
Boundaries
This skill covers public m2cgen usage and export troubleshooting. It does not train models, execute generated programs in foreign runtimes, or reproduce the repository's maintainer-only bulk example generation.
Read references/repo-provenance.md before deciding whether this skill is stale for a changed checkout. The generated skill is self-contained; the original repository's tests, examples, and tools are evidence rather than runtime dependencies.