concrete.ml.sklearn.glm

module concrete.ml.sklearn.glm

Implement sklearn's Generalized Linear Models (GLM).


class PoissonRegressor

A Poisson regression model with FHE.

method __init__

__init__(
    n_bits: 'Union[int, dict]' = 2,
    alpha: 'float' = 1.0,
    fit_intercept: 'bool' = True,
    max_iter: 'int' = 100,
    tol: 'float' = 0.0001,
    warm_start: 'bool' = False,
    verbose: 'int' = 0
)

property fhe_circuit

Get the FHE circuit.

Returns:

  • Circuit: the FHE circuit


property input_quantizers

Get the input quantizers.

Returns:

  • List[QuantizedArray]: the input quantizers


property onnx_model


property output_quantizers

Get the input quantizers.

Returns:

  • List[QuantizedArray]: the input quantizers


property quantize_input

Get the input quantization function.

Returns:

  • Callable : function that quantizes the input


method fit

fit(X, y: 'ndarray', *args, **kwargs)None

Fit the GLM regression quantized model.

Args:

  • X : The training data, which can be: * numpy arrays * torch tensors * pandas DataFrame or Series

  • y (numpy.ndarray): The target data.

  • *args: The arguments to pass to the sklearn linear model.

  • **kwargs: The keyword arguments to pass to the sklearn linear model.


method post_processing

post_processing(
    y_preds: 'ndarray',
    already_dequantized: 'bool' = False
) → ndarray

Post-processing the predictions.

Args:

  • y_preds (numpy.ndarray): The predictions to post-process.

  • already_dequantized (bool): Wether the inputs were already dequantized or not. Default to False.

Returns:

  • numpy.ndarray: The post-processed predictions.


method predict

predict(X: 'ndarray', execute_in_fhe: 'bool' = False) → ndarray

Predict on user data.

Predict on user data using either the quantized clear model, implemented with tensors, or, if execute_in_fhe is set, using the compiled FHE circuit.

Args:

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

  • execute_in_fhe (bool): Whether to execute the inference in FHE. Default to False.

Returns:

  • numpy.ndarray: The model's predictions.


class GammaRegressor

A Gamma regression model with FHE.

method __init__

__init__(
    n_bits: 'Union[int, dict]' = 2,
    alpha: 'float' = 1.0,
    fit_intercept: 'bool' = True,
    max_iter: 'int' = 100,
    tol: 'float' = 0.0001,
    warm_start: 'bool' = False,
    verbose: 'int' = 0
)

property fhe_circuit

Get the FHE circuit.

Returns:

  • Circuit: the FHE circuit


property input_quantizers

Get the input quantizers.

Returns:

  • List[QuantizedArray]: the input quantizers


property onnx_model


property output_quantizers

Get the input quantizers.

Returns:

  • List[QuantizedArray]: the input quantizers


property quantize_input

Get the input quantization function.

Returns:

  • Callable : function that quantizes the input


method fit

fit(X, y: 'ndarray', *args, **kwargs)None

Fit the GLM regression quantized model.

Args:

  • X : The training data, which can be: * numpy arrays * torch tensors * pandas DataFrame or Series

  • y (numpy.ndarray): The target data.

  • *args: The arguments to pass to the sklearn linear model.

  • **kwargs: The keyword arguments to pass to the sklearn linear model.


method post_processing

post_processing(
    y_preds: 'ndarray',
    already_dequantized: 'bool' = False
) → ndarray

Post-processing the predictions.

Args:

  • y_preds (numpy.ndarray): The predictions to post-process.

  • already_dequantized (bool): Wether the inputs were already dequantized or not. Default to False.

Returns:

  • numpy.ndarray: The post-processed predictions.


method predict

predict(X: 'ndarray', execute_in_fhe: 'bool' = False) → ndarray

Predict on user data.

Predict on user data using either the quantized clear model, implemented with tensors, or, if execute_in_fhe is set, using the compiled FHE circuit.

Args:

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

  • execute_in_fhe (bool): Whether to execute the inference in FHE. Default to False.

Returns:

  • numpy.ndarray: The model's predictions.


class TweedieRegressor

A Tweedie regression model with FHE.

method __init__

__init__(
    n_bits: 'Union[int, dict]' = 2,
    power: 'float' = 0.0,
    alpha: 'float' = 1.0,
    fit_intercept: 'bool' = True,
    link: 'str' = 'auto',
    max_iter: 'int' = 100,
    tol: 'float' = 0.0001,
    warm_start: 'bool' = False,
    verbose: 'int' = 0
)

property fhe_circuit

Get the FHE circuit.

Returns:

  • Circuit: the FHE circuit


property input_quantizers

Get the input quantizers.

Returns:

  • List[QuantizedArray]: the input quantizers


property onnx_model


property output_quantizers

Get the input quantizers.

Returns:

  • List[QuantizedArray]: the input quantizers


property quantize_input

Get the input quantization function.

Returns:

  • Callable : function that quantizes the input


method fit

fit(X, y: 'ndarray', *args, **kwargs)None

Fit the GLM regression quantized model.

Args:

  • X : The training data, which can be: * numpy arrays * torch tensors * pandas DataFrame or Series

  • y (numpy.ndarray): The target data.

  • *args: The arguments to pass to the sklearn linear model.

  • **kwargs: The keyword arguments to pass to the sklearn linear model.


method post_processing

post_processing(
    y_preds: 'ndarray',
    already_dequantized: 'bool' = False
) → ndarray

Post-processing the predictions.

Args:

  • y_preds (numpy.ndarray): The predictions to post-process.

  • already_dequantized (bool): Wether the inputs were already dequantized or not. Default to False.

Returns:

  • numpy.ndarray: The post-processed predictions.


method predict

predict(X: 'ndarray', execute_in_fhe: 'bool' = False) → ndarray

Predict on user data.

Predict on user data using either the quantized clear model, implemented with tensors, or, if execute_in_fhe is set, using the compiled FHE circuit.

Args:

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

  • execute_in_fhe (bool): Whether to execute the inference in FHE. Default to False.

Returns:

  • numpy.ndarray: The model's predictions.

Last updated