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

# Base

> systematica.portfolio.transformers.base

## `BaseTransformer`

```python theme={null}
BaseTransformer()
```

Base class for transforming trading metrics.

### Ancestors

* `abc.ABC`

### Descendants

* `systematica.portfolio.transformers.logistic.Logistic`

### Methods

#### `transform`

```python theme={null}
transform(
    self,
    metrics: Dict[str, float],
) ‑> Dict[str, float]
```

Transform metrics based on the selected transformation method.

**Parameters**:

| Name      | Type                  | Default | Description                                                                                                         |
| --------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------- |
| `metrics` | `tp.Dict[str, float]` | `--`    | A dictionary containing performance metrics, where keys are metric names and values are their corresponding values. |

**Returns**:

| Type                  | Description                                                                                                  |
| --------------------- | ------------------------------------------------------------------------------------------------------------ |
| `tp.Dict[str, float]` | A dictionary of transformed metrics, where keys are the same as input and values are the transformed values. |

## `Reward`

```python theme={null}
Reward(
    transformer: systematica.portfolio.transformers.base.BaseTransformer,
    weights: Dict[str, float] = _Nothing.NOTHING,
)
```

Computes a composite reward score.

This class computes a reward score as a weighted sum of processed metrics.
It uses a processor to transform the raw metrics and applies weights to
each metric. The weight for 'max\_drawdown' is inverted because a lower value
is preferable.

Method generated by attrs for class Reward.

### Instance variables

* `transformer: systematica.portfolio.transformers.base.BaseTransformer`: An instance of a transformer to process the metrics. If `None`, defaults to `Logistic`.

* `weights: Dict[str, float]`: A dictionary mapping metric names to weights. Defaults to an empty dictionary.

### Methods

#### `run`

```python theme={null}
run(
    self,
    metrics: Dict[str, float],
) ‑> float
```

Calculate the composite reward score.

This method adjusts specific metrics (e.g., inverting 'max\_drawdown'),
processes the metrics using the assigned processor, and computes a
weighted sum of the processed metrics to derive a composite reward
score.

**Parameters**:

| Name      | Type                  | Default | Description                                                                                                                |
| --------- | --------------------- | ------- | -------------------------------------------------------------------------------------------------------------------------- |
| `metrics` | `tp.Dict[str, float]` | `--`    | A dictionary containing performance metrics. If `max_drawdown` is present, its value will be inverted prior to processing. |

**Returns**:

| Type    | Description                          |
| ------- | ------------------------------------ |
| `float` | The computed composite reward score. |
