concrete.ml.sklearn.tree_to_numpy.md

module concrete.ml.sklearn.tree_to_numpy

Implements the conversion of a tree model to a numpy function.

Global Variables

  • MAX_BITWIDTH_BACKWARD_COMPATIBLE

  • OPSET_VERSION_FOR_ONNX_EXPORT

  • EXPECTED_NUMBER_OF_OUTPUTS_PER_TASK


function tree_to_numpy

tree_to_numpy(
    model: ModelProto,
    x: ndarray,
    framework: str,
    task: Task,
    output_n_bits: Optional[int] = 8
) → Tuple[Callable, List[UniformQuantizer], ModelProto]

Convert the tree inference to a numpy functions using Hummingbird.

Args:

  • model (onnx.ModelProto): The model to convert.

  • x (numpy.ndarray): The input data.

  • framework (str): The framework from which the onnx_model is generated.

  • (options: 'xgboost', 'sklearn')

  • task (Task): The task the model is solving

  • output_n_bits (int): The number of bits of the output.

Returns:

  • Tuple[Callable, List[QuantizedArray], onnx.ModelProto]: A tuple with a function that takes a numpy array and returns a numpy array, QuantizedArray object to quantize and dequantize the output of the tree, and the ONNX model.


class Task

Task enumerate.

Last updated