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

# AgentsPredictorWorker

> AID.selector.interface.AgentsPredictorWorker

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

Step 14: Ensemble Scoring (Candidate Generation).

Generates probability predictions for all learning agents using a target
dataset (typically Out-of-Time samples). This step creates the raw evidence
base used by all subsequent evaluation workers in the Selection Phase.

#### Parameters

**`inputs`** : *`AgentsPredictorInput`*
Custom scoring configuration. If None, resolves defaults from 'test.ml' state.

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

> [!NOTE]
>
> Inputs full schema can be obtained by `ctx.workers.agents_predictor.spec` with main params:
>
> <table>
>   <tbody>
>     <tr><td>`inputs == None`</td><td>→</td><td>pipeline data context</td></tr>
>     <tr><td>`data   != None`</td><td>→</td><td>custom data for agent predictions</td></tr>
>   </tbody>
> </table>

#### Returns

*`AgentsPredictorWorker`*
The populated instance of AgentsPredictorWorker.

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

> [!NOTE]
>
> Registers data into the datasets context:
>
> <table>
>   <tbody>
>     <tr><td>`predictions`</td><td>→</td><td>ctx.datasets.predictions.test.agent1</td></tr>
>     <tr><td>`predictions`</td><td>→</td><td>ctx.datasets.predictions.test.agent2</td></tr>
>     <tr><td>`predictions`</td><td>→</td><td>ctx.datasets.predictions.test.agent3</td></tr>
>     <tr><td>`predictions`</td><td>→</td><td>ctx.datasets.predictions.test.agent4</td></tr>
>     <tr><td>`stats`</td><td>→</td><td>ctx.datasets.stats.agents.prediction</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.agents_predictor.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.agents_predictor.fitters
```

Executing workers with defaults → auto provided by the context:

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
ctx.flow.process('data')        # 1. process workers 0-3 → data load - data stability
ctx.flow.process('encoding')    # 2. process workers 4-9 → train and apply encoding to train and test samples
ctx.flow.process('training')    # 3. process workers 10-13 → agents trainining on encoded train sample
ctx.workers.agents_predictor()  # 4. test sample prediction by agents
```

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.agents_predictor
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
...
```

### 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.agents_predictor.fitter
```

The fitted fitter provides all populated attributes.

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

In the experimenting phase, when various parametrization settings might be under testing    (*note that internal fitter API (fx\_config) can vary with respect to chosen fitter*):

```python theme={"theme":{"light":"dracula-soft","dark":"dracula"}}
cfg = dict(
    target = 'target2',
    preprocess = True
)
agents_predictor = ctx.workers.agents_predictor(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.