> ## 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.

# FeatureCleanerWorker

> AID.data.interface.FeatureCleanerWorker

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

Step 1: Feature Quality Screening.

Enforces data standards by cleaning raw datasets and identifying valid
numerical and categorical features. This step creates the 'clean' lineage.

#### Parameters

**`inputs`** : *`FeCleanerInput`*
Custom cleaning inputs configuration. If None, automatically resolves        'train.raw', 'test.raw', and 'dtypes.raw' from preceding step.

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

> [!NOTE]
>
> Inputs full schema can be obtained by `ctx.workers.fe_cleaner.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 fe\_cleaner training and feature cleaning</td></tr>
>     <tr><td>`test_set  != None`</td><td>→</td><td>custom test data might be provided to apply dtypes by trained model</td></tr>
>     <tr><td>`dtypes    != None`</td><td>→</td><td>custom dtypes of all variables in train\_set to apply on train and test</td></tr>
>   </tbody>
> </table>

#### Returns

*`FeatureCleanerWorker`*
The populated instance of FeatureCleanerWorker.

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

> [!NOTE]
>
> Registers data into the datasets context:
>
> <table>
>   <tbody>
>     <tr><td>`data`</td><td>→</td><td>ctx.datasets.train.clean</td></tr>
>     <tr><td>`data`</td><td>→</td><td>ctx.datasets.test.clean</td></tr>
>     <tr><td>`dtypes`</td><td>→</td><td>ctx.datasets.dtypes.clean</td></tr>
>     <tr><td>`dropped`</td><td>→</td><td>ctx.datasets.dtypes.dropped</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.all.clean</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.num.clean</td></tr>
>     <tr><td>`features`</td><td>→</td><td>ctx.datasets.features.cat.clean</td></tr>
>     <tr><td>`stats`</td><td>→</td><td>ctx.datasets.stats.clean</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.fe_cleaner.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.fe_cleaner.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)
```

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.fe_cleaner
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.fe_cleaner.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.fe_cleaner.fitter
```

The fitted fitter provides all populated attributes.

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
fitter  = ctx.workers.fe_cleaner.fitter
params_ = fitter.params
stats_  = fitter.stats
```

Direct choice and parametrization of internal fitter:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
fx  = ctx.workers.fe_cleaner.fitters[0]
prm = dict(
    max_miss = 0.5,
    max_1val = 0.6,
    max_corr = 0.8,
)
fe_cleaner = ctx.workers.fe_cleaner(fx_choice = fx, fx_params = prm)
```

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

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
cfg = dict(
    time_var     = 'time_var2',
    time_format  = '%Y%m%d',
)
fe_cleaner = ctx.workers.fe_cleaner(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.