# Dimensionality Reduction

**Module:** `sovai.extensions.dimensionality_reduction`

## Functions

### `fillna_df()`

```python
def fillna_df(df, verbose = False)
```

Preprocess the panel data.

**Parameters**

| Parameter | Type | Description      |
| --------- | ---- | ---------------- |
| `df`      | —    | —                |
| `verbose` | —    | Default: `False` |

***

### `check_and_scale_data()`

```python
def check_and_scale_data(df)
```

Check if data is scaled in any fashion, and scale it only if it's not scaled.

**Parameters**

| Parameter | Type | Description |
| --------- | ---- | ----------- |
| `df`      | —    | —           |

**Returns**

* pd.DataFrame: Original or scaled data

***

### `postprocess_reduced_data()`

```python
def postprocess_reduced_data(reduced_data, original_df)
```

Convert reduced data back to panel format.

**Parameters**

| Parameter      | Type | Description |
| -------------- | ---- | ----------- |
| `reduced_data` | —    | —           |
| `original_df`  | —    | —           |

***

### `dimensionality_reduction()`

```python
def dimensionality_reduction(
    df,
    method,
    explained_variance = 0.95,
    n_components = None,
    random_state = 42,
)
```

Apply dimensionality reduction technique.

**Parameters**

| Parameter            | Type | Description                                                                               |
| -------------------- | ---- | ----------------------------------------------------------------------------------------- |
| `df`                 | —    | pandas DataFrame                                                                          |
| `method`             | —    | str, dimensionality reduction method                                                      |
| `explained_variance` | —    | float, amount of variance to be explained (default: 0.95)                                 |
| `n_components`       | —    | int or None, number of components (takes precedence over explained\_variance if provided) |
| `random_state`       | —    | int, random state for reproducibility                                                     |

**Returns**

* reduced\_data: pandas DataFrame with reduced dimensions

***


---

# Agent Instructions: 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:

```
GET https://docs.sov.ai/api-reference/extensions/dimensionality-reduction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
