# 4H MLP Weight Retraining - 2026-06-18

## Goal

Retrain the weak 4H MLP weights after the threshold-only deep sweep failed to produce a promotable setup. The target was a lower-drawdown, more robust 4H candidate without overwriting the current canonical artifact unless the retrain cleared promotion gates.

## Tooling Changes

- Added `--fold-objective {mean,min,mean_min}` to `tools/train_mlp.py`.
  - `mean` preserves the legacy fold-mean Calmar objective.
  - `min` optimizes the worst fold directly.
  - `mean_min` blends `70% mean + 30% min` to penalize weak folds without flattening the search surface as aggressively as `min`.
- Added `--extra-weights` to `tools/run_mlp_deep_sweep.py` so retrained artifacts can be evaluated in the same threshold/generalization sweep without replacing canonical weights.
- Suppressed expected NumPy overflow/divide warnings inside `mlp_forward` when CMA-ES probes extreme candidate weights.

## Retrain Candidates

### Candidate A: `mean_min`, 8x4, seed 101

Command:

```bash
.venv/bin/python tools/train_mlp.py \
  --data data/COINBASE_BTCUSD-4H.csv \
  --hidden 8 4 \
  --phase1-epochs 200 \
  --es-generations 300 \
  --es-popsize 24 \
  --es-sigma 0.04 \
  --l2 0.01 \
  --fold-objective mean_min \
  --seed 101 \
  --out strategies/params/mlp/mlp_weights_COINBASE_BTCUSD_4H_meanmin_8x4_seed101.json
```

Training result:

- Fold objective: `mean_min`
- Best fitness: `-0.3536960134`
- Fold Calmars: `[1.0613, 0.0000, 0.7446, 0.9252, 0.3037, 0.0000]`
- Mean fold Calmar: `0.5058`
- Min fold Calmar: `0.0000`
- Recommended thresholds: entry `-62.77`, exit `-25.66`, confirmation `-132.74`, trailing stop `0.0`

### Candidate B: `min`, 8x4, seed 202

Command:

```bash
.venv/bin/python tools/train_mlp.py \
  --data data/COINBASE_BTCUSD-4H.csv \
  --hidden 8 4 \
  --phase1-epochs 200 \
  --es-generations 300 \
  --es-popsize 24 \
  --es-sigma 0.04 \
  --l2 0.01 \
  --fold-objective min \
  --seed 202 \
  --out strategies/params/mlp/mlp_weights_COINBASE_BTCUSD_4H_min_8x4_seed202.json
```

Training result:

- Fold objective: `min`
- Best fitness: `0.0000009305`
- Fold Calmars: `[0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000]`
- Mean fold Calmar: `0.0000`
- Min fold Calmar: `0.0000`
- Recommended thresholds: entry `-39.84`, exit `-11.57`, confirmation `-24.63`, trailing stop `14.15`

This objective was too harsh for the current 4H search landscape and flattened the CMA-ES surface.

## Sweep Evaluation

Command:

```bash
.venv/bin/python tools/run_mlp_deep_sweep.py \
  --timeframes 4H \
  --samples 5000 \
  --top-k 2000 \
  --extra-weights \
    strategies/params/mlp/mlp_weights_COINBASE_BTCUSD_4H_meanmin_8x4_seed101.json \
    strategies/params/mlp/mlp_weights_COINBASE_BTCUSD_4H_min_8x4_seed202.json
```

Summary output:

- Evaluated candidates: `4,993`
- Sweep file: `results/sweeps/optimization_sweep_strategy_mlp_scores_COINBASE_BTCUSD_4H.csv`
- Summary file: `results/reports/mlp_deep_sweep_summary.csv`
- Promoted: `False`
- Promotable: `False`

Best retrained row:

| Weights | Source | Entry | Exit | Conf | Trail | Suppress Bear | Trades | P&L % | Max DD % | Calmar | P&L/DD | Sub1 Calmar | Sub2 Calmar | WFO Min | WFO Neg | OOS Trades | OOS Sortino | Fragile 0.05 | Fragile 1.0 |
| --- | --- | ---: | ---: | ---: | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| `mlp_weights_COINBASE_BTCUSD_4H_meanmin_8x4_seed101.json` | `local_2` | `-30` | `-20` | `-170` | `30` | `true` | `114` | `1928.68` | `-68.62` | `0.0915` | `0.0` | `0.0505` | `0.1452` | `0.1234` | `0` | `1` | `3.2464` | `13` | `274` |

Best `min` candidate row:

| Weights | Source | Entry | Exit | Conf | Trail | Suppress Bear | Trades | P&L % | Max DD % | Calmar | P&L/DD | Sub1 Calmar | Sub2 Calmar | WFO Min | WFO Neg | OOS Trades | OOS Sortino | Fragile 0.05 | Fragile 1.0 |
| --- | --- | ---: | ---: | ---: | ---: | --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| `mlp_weights_COINBASE_BTCUSD_4H_min_8x4_seed202.json` | `broad` | `-190` | `-200` | `-150` | `30` | `false` | `56` | `1113.47` | `-75.79` | `0.0683` | `0.0` | `-10.0000` | `0.0209` | `-0.3925` | `2` | `6` | `0.5676` | `1` | `24` |

## Decision

Do not promote either candidate.

Candidate A improved WFO robustness versus the current 4H winner, but it still fails the promotion gates because `P&L/DD Ratio` remains `0.0`, OOS coverage is only `1` trade, and fragility counts remain high (`Fragile_0.05=13`, `Fragile_1.0=274`).

Candidate B is worse and should be discarded from consideration.

The canonical 4H artifact remains:

```text
strategies/params/mlp/mlp_weights_COINBASE_BTCUSD_4H.json
```

No Pine preset regeneration is needed because no 4H weights were promoted.

## Next Experiment

The 4H issue appears structural rather than threshold-only:

- retraining can produce a row with non-negative WFO folds,
- but still relies on large drawdowns,
- fails perturbation fragility,
- and has weak OOS trade coverage.

The next useful experiment should change the training/evaluation objective to penalize drawdown and fragility directly, not just fold Calmar. A practical next step is a 4H fitness variant that adds penalties for:

- max drawdown worse than `50%`,
- `P&L/DD Ratio == 0`,
- low OOS trade count,
- threshold perturbation fragility.
