1. Model conversion

Convert a Python model into C code

class emlearn.convert.Model[source]

Inference model powered by emlearn

Wrapper around the underlying C code. Allows using the model in Python code, for evaluation/testing. Follows scikit-learn API conventions.


Run inference, return classes / regression values


Run inference, return probabilities

save(name: str, file: str | None = None) str[source]

Generate C code

  • name – Name for the model. Must be valid C identifier

  • file – Filepath for where to save the C code (optional)


The generated C code


Run inference, return anomaly/outlier scores

emlearn.convert.convert(estimator, kind: str | None = None, method: str = 'loadable', dtype: str = 'float', return_type: str = 'classifier', **kwargs) Model[source]

Convert model to C

  • kind – Explicit name for the type of model. Useful if the model is a subclass of a supported model class

  • method – The inference strategy to use. inline|loadable

  • dtype – Datatype to use for features. Can be used to enable quantization

  • return_type – Return type of the model. ‘classifier’ (default) creates a classifier (output binarized when needed), ‘regressor’ creates a regressor (output type is float).


A Estimator like class, that uses C code for inference