界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
设计与创意 · SKILL.md

m2cgen

m2cgen

【设计与创意】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.

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

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

  1. Confirm that the object is fitted and identify its runtime estimator class.
  2. Select one of the 16 supported target-language exporters; do not infer support from a similar language name.
  3. Use the Python API for an in-memory object or the CLI for pickle/joblib and shell pipelines.
  4. Pass only target-appropriate naming options, then validate the generated source before integrating it into a build.
  5. 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.

我的收藏