Concrete ML
WebsiteLibrariesProducts & ServicesDevelopersSupport
0.5
0.5
  • What is Concrete ML?
  • Getting Started
    • Installation
    • Key Concepts
    • Inference in the Cloud
  • Built-in Models
    • Linear Models
    • Tree-based Models
    • Neural Networks
    • Pandas
    • Built-in Model Examples
  • Deep Learning
    • Using Torch
    • Using ONNX
    • Step-by-Step Guide
    • Deep Learning Examples
    • Debugging Models
  • Advanced topics
    • Quantization
    • Pruning
    • Compilation
    • Production Deployment
    • Advanced Features
  • Developer Guide
    • Workflow
      • Set Up the Project
      • Set Up Docker
      • Documentation
      • Support and Issues
      • Contributing
    • Inner workings
      • Importing ONNX
      • Quantization tools
      • FHE Op-graph design
      • External Libraries
    • API
      • concrete.ml.common
      • concrete.ml.common.check_inputs
      • concrete.ml.common.debugging
      • concrete.ml.common.debugging.custom_assert
      • concrete.ml.common.utils
      • concrete.ml.deployment
      • concrete.ml.deployment.fhe_client_server
      • concrete.ml.onnx
      • concrete.ml.onnx.convert
      • concrete.ml.onnx.onnx_model_manipulations
      • concrete.ml.onnx.onnx_utils
      • concrete.ml.onnx.ops_impl
      • concrete.ml.quantization
      • concrete.ml.quantization.base_quantized_op
      • concrete.ml.quantization.post_training
      • concrete.ml.quantization.quantized_module
      • concrete.ml.quantization.quantized_ops
      • concrete.ml.quantization.quantizers
      • concrete.ml.sklearn
      • concrete.ml.sklearn.base
      • concrete.ml.sklearn.glm
      • concrete.ml.sklearn.linear_model
      • concrete.ml.sklearn.protocols
      • concrete.ml.sklearn.qnn
      • concrete.ml.sklearn.rf
      • concrete.ml.sklearn.svm
      • concrete.ml.sklearn.torch_module
      • concrete.ml.sklearn.tree
      • concrete.ml.sklearn.tree_to_numpy
      • concrete.ml.sklearn.xgb
      • concrete.ml.torch
      • concrete.ml.torch.compile
      • concrete.ml.torch.numpy_module
      • concrete.ml.version
Powered by GitBook

Libraries

  • TFHE-rs
  • Concrete
  • Concrete ML
  • fhEVM

Developers

  • Blog
  • Documentation
  • Github
  • FHE resources

Company

  • About
  • Introduction to FHE
  • Media
  • Careers
On this page
  • module concrete.ml.sklearn.linear_model
  • class LinearRegression
  • class ElasticNet
  • class Lasso
  • class Ridge
  • class LogisticRegression

Was this helpful?

Export as PDF
  1. Developer Guide
  2. API

concrete.ml.sklearn.linear_model

Previousconcrete.ml.sklearn.glmNextconcrete.ml.sklearn.protocols

Last updated 2 years ago

Was this helpful?

module concrete.ml.sklearn.linear_model

Implement sklearn linear model.


class LinearRegression

A linear regression model with FHE.

Arguments:

  • n_bits (int): default is 2.

  • use_sum_workaround (bool): indicate if the sum workaround should be used or not. This

  • feature is experimental and should be used carefully. Important note: it only works for a LinearRegression model with N features, N a power of 2, for now. More information available in the QuantizedReduceSum operator. Default to False.

For more details on LinearRegression please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html

method __init__

__init__(
    n_bits=2,
    use_sum_workaround=False,
    fit_intercept=True,
    normalize='deprecated',
    copy_X=True,
    n_jobs=None,
    positive=False
)

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

Get the ONNX model.

.. # noqa: DAR201

Returns:

  • onnx.ModelProto: the 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) → Any

Fit the FHE linear model.

Args:

  • X : training data By default, you should be able to pass: * 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.

Returns: Any


class ElasticNet

An ElasticNet regression model with FHE.

Arguments:

  • n_bits (int): default is 2.

For more details on ElasticNet please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html

method __init__

__init__(
    n_bits=2,
    alpha=1.0,
    l1_ratio=0.5,
    fit_intercept=True,
    normalize='deprecated',
    copy_X=True,
    positive=False
)

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

Get the ONNX model.

.. # noqa: DAR201

Returns:

  • onnx.ModelProto: the 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


class Lasso

A Lasso regression model with FHE.

Arguments:

  • n_bits (int): default is 2.

For more details on Lasso please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html

method __init__

__init__(
    n_bits=2,
    alpha: float = 1.0,
    fit_intercept=True,
    normalize='deprecated',
    copy_X=True,
    positive=False
)

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

Get the ONNX model.

.. # noqa: DAR201

Returns:

  • onnx.ModelProto: the 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


class Ridge

A Ridge regression model with FHE.

Arguments:

  • n_bits (int): default is 2.

For more details on Ridge please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html

method __init__

__init__(
    n_bits=2,
    alpha: float = 1.0,
    fit_intercept=True,
    normalize='deprecated',
    copy_X=True,
    positive=False
)

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

Get the ONNX model.

.. # noqa: DAR201

Returns:

  • onnx.ModelProto: the 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


class LogisticRegression

A logistic regression model with FHE.

Arguments:

  • n_bits (int): default is 2.

For more details on LogisticRegression please refer to the scikit-learn documentation: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LogisticRegression.html

method __init__

__init__(
    n_bits=2,
    penalty='l2',
    dual=False,
    tol=0.0001,
    C=1.0,
    fit_intercept=True,
    intercept_scaling=1,
    class_weight=None,
    random_state=None,
    solver='lbfgs',
    max_iter=100,
    multi_class='auto',
    verbose=0,
    warm_start=False,
    n_jobs=None,
    l1_ratio=None
)

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

Get the ONNX model.

.. # noqa: DAR201

Returns:

  • onnx.ModelProto: the 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