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

# WoeStabilizerWorker

> AID.data.interface.WoeStabilizerWorker

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
from AID.data.interface import WoeStabilizerWorker
```

Step 8: WOE Feature Stability Validation.

The final transformation guardrail. Screens WOE-encoded features for
temporal stability to ensure the encoding is robust across data folds.

#### Parameters

**`inputs`** : *`WoeStabilizerInput`*
Custom stability configuration. If None, resolves from 'train.stable',        'test.clean' and 'features.encoded.woe'.

**`**kwargs`** : *`dict`*
Additional parameters passed to the WoeStabilizer worker.

> [!NOTE]
>
> Inputs full schema can be obtained by `ctx.workers.woe_stabilizer.spec` with main params:
>
> <table>
>   <tbody>
>     <tr><td>`inputs    == None`</td><td>→</td><td>pipeline data context</td></tr>
>     <tr><td>`train_set != None`</td><td>→</td><td>custom train data for woe\_stabilizer training</td></tr>
>     <tr><td>`test_set  != None`</td><td>→</td><td>custom test data for woe\_stabilizer assessment view</td></tr>
>     <tr><td>`woe_features != None`</td><td>→</td><td>custom subset of woe encoded vars</td></tr>
>   </tbody>
> </table>

#### Returns

*`WoeStabilizerWorker`*
The populated instance of WoeStabilizerWorker.

> [!NOTE]
>
> Populates attributes into the worker context:
>
> <table>
>   <tbody>
>     <tr><td>`model`</td><td>→</td><td>ctx.workers.woe\_stabilizer</td></tr>
>     <tr><td>`inputs`</td><td>→</td><td>ctx.workers.woe\_stabilizer.spec</td></tr>
>     <tr><td>`result`</td><td>→</td><td>ctx.workers.woe\_stabilizer.result</td></tr>
>     <tr><td>`state`</td><td>→</td><td>ctx.workers.woe\_stabilizer.state</td></tr>
>     <tr><td>`report`</td><td>→</td><td>ctx.workers.woe\_stabilizer.report</td></tr>
>     <tr><td>`stats`</td><td>→</td><td>ctx.workers.woe\_stabilizer.stats</td></tr>
>     <tr><td>`fitter`</td><td>→</td><td>ctx.workers.woe\_stabilizer.fitter</td></tr>
>   </tbody>
> </table>

> [!NOTE]
>
> Registers data into the datasets context:
>
> <table>
>   <tbody>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.woe.stable</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.all.stable.target</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.num.stable.target</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.cat.stable.target</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.ixn.stable.target</td></tr>
>     <tr><td>`dropped`</td><td>→</td><td>ctx.datasets.features.woe.dropped.stable</td></tr>
>     <tr><td>`dropped`</td><td>→</td><td>ctx.datasets.features.all.dropped.stable.target</td></tr>
>     <tr><td>`dropped`</td><td>→</td><td>ctx.datasets.features.num.dropped.stable.target</td></tr>
>     <tr><td>`dropped`</td><td>→</td><td>ctx.datasets.features.cat.dropped.stable.target</td></tr>
>     <tr><td>`dropped`</td><td>→</td><td>ctx.datasets.features.ixn.dropped.stable.target</td></tr>
>     <tr><td>`stats`</td><td>→</td><td>ctx.datasets.stats.encoded.woe.stable</td></tr>
>   </tbody>
> </table>

#### Examples

Defining the Project Context (Control Plane) & Project Scope:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
import aidflow as aid

ctx = aid.ProjectContext()

ctx.genesis(
    project      = 'test',
    input_data   = 'test.csv',
    target       = 'target',
    yy_mm        = 'decision_date',
    yy_mm_format = '%Y-%m-%d'
)
ctx.params()
```

### Worker → Model → Fitter

Accessing worker's inputs schema → parameters & types (*shown in the display output*):

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.workers.woe_stabilizer.spec
```

Accessing model's fitter options and schema → parameters & types
(*shown in the display output*):

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.workers.woe_stabilizer.fitters
```

Executing workers with defaults → auto provided by the context:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.workers.data_loader()    # 0. import data to the context scope
ctx.workers.fe_cleaner()     # 1. apply cleaning logic to the imported data (0)
ctx.workers.fe_stabilizer()  # 2. apply temporal stability logic to the cleaned data (1)
ctx.workers.obs_stabilizer() # 3. apply observation stability logic to the cleaned data (2)
ctx.workers.num_encoder()    # 4. apply numerical encoding logic to the stable data (3)
ctx.workers.cat_encoder()    # 5. apply categorical encoding logic to the stable data (3)
ctx.workers.ixn_encoder()    # 6. apply interactions encoding logic to the stable data (3)
ctx.workers.woe_encoder()    # 7. apply woe encoding logic using trained encoding in steps (4-5-6)
ctx.workers.woe_stabilizer() # 8. apply woe stabilization logic using trained woe encoding in step (7)
```

Note that steps 0-3 can be run by ExecutionContext one-liner:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.flow.process('data', verbose = 0) # steps 0 - 3 have been trained within the context scope
```

Once worker has been executed, thus its main model has been built,    we have access to all populated attributes.

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
worker   = ctx.workers.woe_stabilizer
inputs   = worker.spec.inputs
result   = worker.result
state    = worker.state
features = worker.features
params   = worker.params
stats    = worker.stats
fitter   = worker.fitter  # jump to chosen internal fitter
...
```

View to model report of executed worker:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.workers.woe_stabilizer.report.show()
```

### Model → Fitter

Once worker has been executed, we can obtain internal fitter state    and its parametrization (*shown in the display output*):

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.workers.woe_stabilizer.fitter
```

The fitted fitter provides all populated attributes.

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
fitter    = ctx.workers.woe_stabilizer.fitter
result_   = fitter.result
features_ = fitter.features
params_   = fitter.params
stats_    = fitter.stats
```

Direct choice and parametrization of internal fitter:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
fx  = ctx.workers.woe_stabilizer.fitters[0]
prm = dict(
        stability_cutoff = 0.8,
        alpha = 0.01
)
woe_stabilizer = ctx.workers.woe_stabilizer(fx_choice = fx, fx_params = prm)
```

In the experimenting phase when various targets might be under testing    (*note that 'target2' and 'time\_var2' must be present in the data*):

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
cfg = dict(
    target   = 'target2',
    time_var = 'time_var2',
)
woe_stabilizer = ctx.workers.woe_stabilizer(fx_config = cfg)
```

#### Attributes

> [!NOTE]
>
> All worker attributes return `None` prior its execution.

| Attribute | Type | Description |
| :- | :- | :- |
| `inputs` | `ModelInput` | Registered populated inputs containing execution timestamps and feature definitions. |
| `result` | `ModelResult` | Execution output payload containing model predictions and fit results. |
| `fitter` | `Fitter` | Underlying fitted estimator instance. |
| `state` | `ModelState` | Consolidated model state (fitter, choice, params, features, report, stats). |
| `report` | `DashboardInterface` | Interactive report interface. Call `report.show()` to render the visualization dashboard. |
| `stats` | `FitStats` | Performance metrics and training metadata gathered during fitting. |
| `features` | `TransResCols` | Feature schema dataclass required for downstream inference. |
| `params` | `tuple[FitParams, Parameters, ...]` | Tuple of fit settings, execution parameters, optionally transformer parameters. |
| `choice` | `RegGet.Choice` | Active configuration parameters including internal fitter choice (`fx_choice`). |
| `model_signature` | `str` | Unique hash identifier for the fitted model instance. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.