> For the complete documentation index, see [llms.txt](https://docs.seldon.ai/alibi-explain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seldon.ai/alibi-explain/api-reference/utils/approximation_methods.md).

# alibi.utils.approximation\_methods

## Constants

### `SUPPORTED_RIEMANN_METHODS`

```python
SUPPORTED_RIEMANN_METHODS: list = ['riemann_left', 'riemann_right', 'riemann_middle', 'riemann_trapezoid']
```

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

### `SUPPORTED_METHODS`

```python
SUPPORTED_METHODS: list = ['riemann_left', 'riemann_right', 'riemann_middle', 'riemann_trapezoid', 'gau...
```

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

## `Riemann`

*Inherits from:* `Enum`

An enumeration.

## Functions

### `approximation_parameters`

```python
approximation_parameters(method: str) -> Tuple[Callable[[.[<class 'int'>]], List[float]], Callable[[.[<class 'int'>]], List[float]]]
```

Retrieves parameters for the input approximation `method`.

| Name     | Type  | Default | Description                                                                                                                                                                                                              |
| -------- | ----- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `method` | `str` |         | The name of the approximation method. Currently supported only: `'riemann_*'` and `'gausslegendre`'. Check :py:data:`alibi.utils.approximation_methods.SUPPORTED_RIEMANN_METHODS` for all `'riemann_*'` possible values. |

**Returns**

* Type: `Tuple[Callable[[.[<class 'int'>]], List[float]], Callable[[.[<class 'int'>]], List[float]]]`

### `gauss_legendre_builders`

```python
gauss_legendre_builders() -> Tuple[Callable[[.[<class 'int'>]], List[float]], Callable[[.[<class 'int'>]], List[float]]]
```

`np.polynomial.legendre` function helps to compute step sizes and alpha coefficients using gauss-legendre quadrature rule. Since `numpy` returns the integration parameters in different scales we need to rescale them to adjust to the desired scale.

Gauss Legendre quadrature rule for approximating the integrals was originally proposed by \[Xue Feng and her intern Hauroun Habeeb] (<https://research.fb.com/people/feng-xue/>).

| Name | Type | Default | Description                      |
| ---- | ---- | ------- | -------------------------------- |
| `n`  |      |         | The number of integration steps. |

**Returns**

* Type: `Tuple[Callable[[.[<class 'int'>]], List[float]], Callable[[.[<class 'int'>]], List[float]]]`

### `riemann_builders`

```python
riemann_builders(method: alibi.utils.approximation_methods.Riemann = <Riemann.trapezoid: 4>) -> Tuple[Callable[[.[<class 'int'>]], List[float]], Callable[[.[<class 'int'>]], List[float]]]
```

Step sizes are identical and alphas are scaled in \[0, 1].

| Name     | Type                                        | Default                  | Description                      |
| -------- | ------------------------------------------- | ------------------------ | -------------------------------- |
| `method` | `alibi.utils.approximation_methods.Riemann` | `<Riemann.trapezoid: 4>` | Riemann method: `Riemann.left`   |
| `n`      |                                             |                          | The number of integration steps. |

**Returns**

* Type: `Tuple[Callable[[.[<class 'int'>]], List[float]], Callable[[.[<class 'int'>]], List[float]]]`


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.seldon.ai/alibi-explain/api-reference/utils/approximation_methods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
