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.

predict(X)[source]

Run inference, return classes / regression values

predict_proba(X)[source]

Run inference, return probabilities

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

Generate C code

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

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

Returns:

The generated C code

score_samples(X)[source]

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

Parameters:
  • 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).

Returns:

A Estimator like class, that uses C code for inference