> For the complete documentation index, see [llms.txt](https://docs.zama.org/concrete-ml/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/concrete-ml/0.6-1/developer-guide/api/concrete.ml.sklearn.glm.md).

# concrete.ml.sklearn.glm.md

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L0)

## module `concrete.ml.sklearn.glm`

Implement sklearn's Generalized Linear Models (GLM).

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L134)

### class `PoissonRegressor`

A Poisson regression model with FHE.

**Parameters:**

* `n_bits` (int, Dict\[str, int]): Number of bits to quantize the model. If an int is passed for n\_bits, the value will be used for quantizing inputs and weights. If a dict is passed, then it should contain "op\_inputs" and "op\_weights" as keys with corresponding number of quantization bits so that: - op\_inputs : number of bits to quantize the input values - op\_weights: number of bits to quantize the learned parameters Default to 8.

For more details on PoissonRegressor please refer to the scikit-learn documentation: <https://scikit-learn.org/stable/modules/generated/sklearn.linear\\_model.PoissonRegressor.html>

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L155)

#### method `__init__`

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

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L54)

#### method `post_processing`

```python
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): Whether the inputs were already dequantized or not. Default to False.

**Returns:**

* `numpy.ndarray`: The post-processed predictions.

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L75)

#### method `predict`

```python
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.

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L190)

### class `GammaRegressor`

A Gamma regression model with FHE.

**Parameters:**

* `n_bits` (int, Dict\[str, int]): Number of bits to quantize the model. If an int is passed for n\_bits, the value will be used for quantizing inputs and weights. If a dict is passed, then it should contain "op\_inputs" and "op\_weights" as keys with corresponding number of quantization bits so that: - op\_inputs : number of bits to quantize the input values - op\_weights: number of bits to quantize the learned parameters Default to 8.

For more details on GammaRegressor please refer to the scikit-learn documentation: <https://scikit-learn.org/stable/modules/generated/sklearn.linear\\_model.GammaRegressor.html>

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L211)

#### method `__init__`

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

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L54)

#### method `post_processing`

```python
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): Whether the inputs were already dequantized or not. Default to False.

**Returns:**

* `numpy.ndarray`: The post-processed predictions.

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L75)

#### method `predict`

```python
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.

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L246)

### class `TweedieRegressor`

A Tweedie regression model with FHE.

**Parameters:**

* `n_bits` (int, Dict\[str, int]): Number of bits to quantize the model. If an int is passed for n\_bits, the value will be used for quantizing inputs and weights. If a dict is passed, then it should contain "op\_inputs" and "op\_weights" as keys with corresponding number of quantization bits so that: - op\_inputs : number of bits to quantize the input values - op\_weights: number of bits to quantize the learned parameters Default to 8.

For more details on TweedieRegressor please refer to the scikit-learn documentation: <https://scikit-learn.org/stable/modules/generated/sklearn.linear\\_model.TweedieRegressor.html>

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L267)

#### method `__init__`

```python
__init__(
    n_bits: 'Union[int, dict]' = 8,
    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
)
```

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L54)

#### method `post_processing`

```python
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): Whether the inputs were already dequantized or not. Default to False.

**Returns:**

* `numpy.ndarray`: The post-processed predictions.

***

[![](https://img.shields.io/badge/-source-cccccc?style=flat-square)](https://github.com/zama-ai/concrete-ml/tree/release/0.6.x/src/concrete/ml/sklearn/glm.py#L75)

#### method `predict`

```python
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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/concrete-ml/0.6-1/developer-guide/api/concrete.ml.sklearn.glm.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
