> ## Documentation Index
> Fetch the complete documentation index at: https://nixtlaverse.nixtla.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Scalers

> Scale arrays

##

### `boxcox_lambda`

```python theme={null}
boxcox_lambda(x, method, season_length=None, lower=-0.9, upper=2.0)
```

Find optimum lambda for the Box-Cox transformation

**Parameters:**

| Name            | Type                                   | Description                                                                                                                                                                                                    | Default           |
| --------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| `x`             | <code>[ndarray](#numpy.ndarray)</code> | Array with data to transform.                                                                                                                                                                                  | *required*        |
| `method`        | <code>[str](#str)</code>               | Method to use. Valid options are 'guerrero' and 'loglik'. 'guerrero' minimizes the coefficient of variation for subseries of `x` and supports negative values. 'loglik' maximizes the log-likelihood function. | *required*        |
| `season_length` | <code>[int](#int)</code>               | Length of the seasonal period. Only required if method='guerrero'.                                                                                                                                             | <code>None</code> |
| `lower`         | <code>[float](#float)</code>           | Lower bound for the lambda.                                                                                                                                                                                    | <code>-0.9</code> |
| `upper`         | <code>[float](#float)</code>           | Upper bound for the lambda.                                                                                                                                                                                    | <code>2.0</code>  |

**Returns:**

| Name    | Type                         | Description     |
| ------- | ---------------------------- | --------------- |
| `float` | <code>[float](#float)</code> | Optimum lambda. |

### `boxcox`

```python theme={null}
boxcox(x, lmbda)
```

Apply the Box-Cox transformation

**Parameters:**

| Name    | Type                                   | Description                   | Default    |
| ------- | -------------------------------------- | ----------------------------- | ---------- |
| `x`     | <code>[ndarray](#numpy.ndarray)</code> | Array with data to transform. | *required* |
| `lmbda` | <code>[float](#float)</code>           | Lambda value to use.          | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

### `inv_boxcox`

```python theme={null}
inv_boxcox(x, lmbda)
```

Invert the Box-Cox transformation

**Parameters:**

| Name    | Type                                   | Description                   | Default    |
| ------- | -------------------------------------- | ----------------------------- | ---------- |
| `x`     | <code>[ndarray](#numpy.ndarray)</code> | Array with data to transform. | *required* |
| `lmbda` | <code>[float](#float)</code>           | Lambda value to use.          | *required* |

**Returns:**

| Type                                   | Description                                         |
| -------------------------------------- | --------------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the inverted transformation. |

### `LocalMinMaxScaler`

```python theme={null}
LocalMinMaxScaler(skipna=False)
```

Bases: <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code>

Scale each group to the \[0, 1] interval

**Parameters:**

| Name     | Type                       | Description                                                                                                                            | Default            |
| -------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `skipna` | <code>[bool](#bool)</code> | If True, exclude NaN values when computing statistics. When False (default), NaN values are included and may result in NaN statistics. | <code>False</code> |

#### `LocalMinMaxScaler.fit`

```python theme={null}
fit(ga)
```

Compute the statistics for each group.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Name   | Type                                                                     | Description               |
| ------ | ------------------------------------------------------------------------ | ------------------------- |
| `self` | <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code> | The fitted scaler object. |

#### `LocalMinMaxScaler.fit_transform`

```python theme={null}
fit_transform(ga)
```

"Compute the statistics for each group and apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

#### `LocalMinMaxScaler.inverse_transform`

```python theme={null}
inverse_transform(ga)
```

Use the computed statistics to invert the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                         |
| -------------------------------------- | --------------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the inverted transformation. |

#### `LocalMinMaxScaler.stack`

```python theme={null}
stack(scalers)
```

#### `LocalMinMaxScaler.take`

```python theme={null}
take(idxs)
```

#### `LocalMinMaxScaler.transform`

```python theme={null}
transform(ga)
```

Use the computed statistics to apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

### `LocalStandardScaler`

```python theme={null}
LocalStandardScaler(skipna=False)
```

Bases: <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code>

Scale each group to have zero mean and unit variance

**Parameters:**

| Name     | Type                       | Description                                                                                                                            | Default            |
| -------- | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| `skipna` | <code>[bool](#bool)</code> | If True, exclude NaN values when computing statistics. When False (default), NaN values are included and may result in NaN statistics. | <code>False</code> |

#### `LocalStandardScaler.fit`

```python theme={null}
fit(ga)
```

Compute the statistics for each group.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Name   | Type                                                                     | Description               |
| ------ | ------------------------------------------------------------------------ | ------------------------- |
| `self` | <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code> | The fitted scaler object. |

#### `LocalStandardScaler.fit_transform`

```python theme={null}
fit_transform(ga)
```

"Compute the statistics for each group and apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

#### `LocalStandardScaler.inverse_transform`

```python theme={null}
inverse_transform(ga)
```

Use the computed statistics to invert the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                         |
| -------------------------------------- | --------------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the inverted transformation. |

#### `LocalStandardScaler.stack`

```python theme={null}
stack(scalers)
```

#### `LocalStandardScaler.take`

```python theme={null}
take(idxs)
```

#### `LocalStandardScaler.transform`

```python theme={null}
transform(ga)
```

Use the computed statistics to apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

### `LocalRobustScaler`

```python theme={null}
LocalRobustScaler(scale, skipna=False)
```

Bases: <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code>

Scale each group using robust statistics

**Parameters:**

| Name     | Type                       | Description                                                                                                                                                                          | Default            |
| -------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------ |
| `scale`  | <code>[str](#str)</code>   | Type of robust scaling to use. Valid options are 'iqr' and 'mad'. If 'iqr' will use the inter quartile range as the scale. If 'mad' will use median absolute deviation as the scale. | *required*         |
| `skipna` | <code>[bool](#bool)</code> | If True, exclude NaN values when computing statistics. When False (default), NaN values are included and may result in NaN statistics.                                               | <code>False</code> |

#### `LocalRobustScaler.fit`

```python theme={null}
fit(ga)
```

Compute the statistics for each group.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Name   | Type                                                                     | Description               |
| ------ | ------------------------------------------------------------------------ | ------------------------- |
| `self` | <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code> | The fitted scaler object. |

#### `LocalRobustScaler.fit_transform`

```python theme={null}
fit_transform(ga)
```

"Compute the statistics for each group and apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

#### `LocalRobustScaler.inverse_transform`

```python theme={null}
inverse_transform(ga)
```

Use the computed statistics to invert the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                         |
| -------------------------------------- | --------------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the inverted transformation. |

#### `LocalRobustScaler.stack`

```python theme={null}
stack(scalers)
```

#### `LocalRobustScaler.take`

```python theme={null}
take(idxs)
```

#### `LocalRobustScaler.transform`

```python theme={null}
transform(ga)
```

Use the computed statistics to apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

### `LocalBoxCoxScaler`

```python theme={null}
LocalBoxCoxScaler(method, season_length=None, lower=-0.9, upper=2.0)
```

Bases: <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code>

Find the optimum lambda for the Box-Cox transformation by group and apply it

**Parameters:**

| Name            | Type                         | Description                                                                                                                                                                                                    | Default           |
| --------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| `season_length` | <code>[int](#int)</code>     | Length of the seasonal period. Only required if method='guerrero'.                                                                                                                                             | <code>None</code> |
| `lower`         | <code>[float](#float)</code> | Lower bound for the lambda.                                                                                                                                                                                    | <code>-0.9</code> |
| `upper`         | <code>[float](#float)</code> | Upper bound for the lambda.                                                                                                                                                                                    | <code>2.0</code>  |
| `method`        | <code>[str](#str)</code>     | Method to use. Valid options are 'guerrero' and 'loglik'. 'guerrero' minimizes the coefficient of variation for subseries of `x` and supports negative values. 'loglik' maximizes the log-likelihood function. | *required*        |

#### `LocalBoxCoxScaler.fit`

```python theme={null}
fit(ga)
```

Compute the statistics for each group.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Name   | Type                                                                     | Description               |
| ------ | ------------------------------------------------------------------------ | ------------------------- |
| `self` | <code>[\_BaseLocalScaler](#coreforecast.scalers._BaseLocalScaler)</code> | The fitted scaler object. |

#### `LocalBoxCoxScaler.fit_transform`

```python theme={null}
fit_transform(ga)
```

"Compute the statistics for each group and apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

#### `LocalBoxCoxScaler.inverse_transform`

```python theme={null}
inverse_transform(ga)
```

Use the computed lambdas to invert the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                         |
| -------------------------------------- | --------------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the inverted transformation. |

#### `LocalBoxCoxScaler.stack`

```python theme={null}
stack(scalers)
```

#### `LocalBoxCoxScaler.take`

```python theme={null}
take(idxs)
```

#### `LocalBoxCoxScaler.transform`

```python theme={null}
transform(ga)
```

Use the computed lambdas to apply the transformation.

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

### `Difference`

```python theme={null}
Difference(d)
```

Subtract a lag to each group

**Parameters:**

| Name | Type                     | Description      | Default    |
| ---- | ------------------------ | ---------------- | ---------- |
| `d`  | <code>[int](#int)</code> | Lag to subtract. | *required* |

#### `Difference.fit_transform`

```python theme={null}
fit_transform(ga)
```

Apply the transformation

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                  |
| -------------------------------------- | -------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the transformed data. |

#### `Difference.inverse_transform`

```python theme={null}
inverse_transform(ga)
```

Invert the transformation

**Parameters:**

| Name | Type                                                                       | Description              | Default    |
| ---- | -------------------------------------------------------------------------- | ------------------------ | ---------- |
| `ga` | <code>[GroupedArray](#coreforecast._lib.grouped_array.GroupedArray)</code> | Array with grouped data. | *required* |

**Returns:**

| Type                                   | Description                                         |
| -------------------------------------- | --------------------------------------------------- |
| <code>[ndarray](#numpy.ndarray)</code> | np.ndarray: Array with the inverted transformation. |

#### `Difference.stack`

```python theme={null}
stack(scalers)
```

#### `Difference.take`

```python theme={null}
take(idxs)
```
