# LogitScaler

**Compatibility:** `numerical` data

The `LogitScaler` performs a statistical transformation on numerical data. It computes the [Logit function](https://en.wikipedia.org/wiki/Logit) to convert the scale and shape of the data. You can optionally choose the min and max values of the Logit function, effectively enforcing the min/max boundaries on your data.

<figure><img src="https://2225246359-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVGX92M819eIp0rMg5elc%2Fuploads%2FvXhQkcxgPs6ZFjqR02BZ%2Frdt_transformers-glossary-numerical-logitscaler_June%2003%202025.png?alt=media&#x26;token=4564e805-9277-4c3e-8cf2-2ead6ea3ff7a" alt=""><figcaption></figcaption></figure>

```python
from rdt.transformers.numerical import LogitScaler

transformer = LogitScaler(min_value=0, max_value=100)
```

## Parameters

**`missing_value_replacement`**: Add this argument to replace missing values during the transform phase

<table data-header-hidden><thead><tr><th width="212"></th><th></th></tr></thead><tbody><tr><td>(default) <code>'mean'</code></td><td>Replace all missing values with the average value.</td></tr><tr><td><code>'random'</code></td><td>Replace missing values with a random value. The value is chosen uniformly at random from the min/max range.</td></tr><tr><td><code>'mode'</code></td><td>Replace all missing values with the most frequently occurring value</td></tr><tr><td><code>&#x3C;number></code></td><td>Replace all missing values with the specified number (<code>0</code>, <code>-1</code>, <code>0.5</code>, etc.)</td></tr><tr><td><code>None</code></td><td>Do not replace missing values. The transformed data will continue to have missing values.</td></tr></tbody></table>

**`missing_value_generation`**: Add this argument to determine how to recreate missing values during the reverse transform phase

<table data-header-hidden><thead><tr><th width="203"></th><th></th></tr></thead><tbody><tr><td>(default) <code>'random'</code></td><td>Randomly assign missing values in roughly the same proportion as the original data.</td></tr><tr><td><code>'from_column'</code></td><td>Create a new column to store whether the value should be missing. Use it to recreate missing values. <em>Note: Adding extra columns uses more memory and increases the RDT processing time.</em></td></tr><tr><td><code>None</code></td><td>Do not recreate missing values.</td></tr></tbody></table>

**`min_value`**: The min value for the Logit function.  The Logit function of anything ≤ this value is undefined.

<table data-header-hidden><thead><tr><th width="262.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>0</code></td><td>The min value of the function is 0.</td></tr><tr><td><code>&#x3C;float></code></td><td>A floating point value that acts as as the min value of the Logit function.</td></tr></tbody></table>

**`max_value`**: The max value for the Logit function.  The Logit function of anything ≥ this value is undefined.

<table data-header-hidden><thead><tr><th width="270.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>1</code></td><td>The max value of the function is 1.</td></tr><tr><td><code>&#x3C;float></code></td><td>A floating point value that acts as as the max value of the Logit function.</td></tr></tbody></table>

**`learn_rounding_scheme`**: Add this argument to allow the transformer to learn about rounded values in your dataset.

<table data-header-hidden><thead><tr><th width="249.5"></th><th></th></tr></thead><tbody><tr><td>(default) <code>False</code></td><td>Do not learn or enforce any rounding scheme. When reverse transforming the data, there may be many decimal places present.</td></tr><tr><td><code>True</code></td><td>Learn the rounding rules from the input data. When reverse transforming the data, round the number of digits to match the original.</td></tr></tbody></table>

## FAQ

<details>

<summary>How do I enforce min/max values with this transformer?</summary>

This transformer enforces strict minimum and maximum boundaries on your data using the `min_value` and `max_value` parameters.

If you'd like the minimum or maximum value to be allowed, we suggest setting the boundary to something slightly outside the range that you need.

```python
from rdt.transformers.numerical import LogitScaler
transformer = LogitScaler(
    min_value=0.0 - 1e-10, # allow a value of exactly 0 
    max_value=10.0 + 1e-10 # allow a value of exactly 10
)
```

If you'd like to enforce singular boundary (min or max) instead, please use the [LogScaler](https://docs.sdv.dev/rdt/transformers-glossary/numerical/logscaler).

</details>
