# Fuzzy TSK Baseline and IT2 Comparison

Run the complete test suite from the project root with:

```powershell
d:\anaconda3\python.exe -m pytest -v
```

Run the Type-1 baseline with:

```powershell
d:\anaconda3\python.exe experiments\t1_baseline.py
```

The experiment uses a fixed seed, a synthetic `y = sin(x)` dataset, and a
fixed train/test split. The model and feature standardization are fitted only
on the training subset. It writes `results/t1_baseline_predictions.csv` and
`results/t1_baseline_metrics.csv`.

Run the Type-1 versus Interval Type-2 comparison with:

```powershell
d:\anaconda3\python.exe experiments\it2_comparison.py
```

This uses the same fixed split and training-only preprocessing for both
models, with IT2 width uncertainty `delta=0.2`. It writes
`results/t1_it2_comparison_predictions.csv` and
`results/t1_it2_comparison_metrics.csv`.

Run the robustness benchmark with 10 fixed seeds and three input-noise levels:

```powershell
d:\anaconda3\python.exe experiments\robustness_experiment.py
d:\anaconda3\python.exe experiments\plot_robustness.py
```

The benchmark uses seeds `0` through `9`, noise levels `0.0`, `0.1`, and
`0.3`, and IT2 `delta=0.2` chosen before evaluation. For each seed, the
dataset is split into 168 training and 72 test points using a seeded
permutation. Input noise is independently sampled for train and test as
`Normal(0, (alpha * std(X_train_clean))^2)`, where the scale is estimated
from that seed's clean training inputs only. Both models receive identical
noisy train/test arrays for each condition, and targets remain noiseless
`sin(x)` values.

The benchmark writes:

- `results/t1_it2_robustness_raw.csv`: 60 per-model runs with RMSE, MAE,
	and paired IT2-minus-Type-1 differences.
- `results/t1_it2_robustness_aggregate.csv`: means, sample standard
	deviations, run counts, and paired-difference summaries by noise level.
- `results/t1_it2_robustness_metrics.png`: RMSE and MAE plots with standard
	deviation error bars.

This is a synthetic benchmark on one function and is not evidence of
real-world superiority. It reports no statistical significance; broader
datasets, repeated experimental designs, and justified statistical tests
would be needed for that conclusion.

Regenerate the mathematical visualization figures with:

```powershell
d:\anaconda3\python.exe experiments\plot_model_visualizations.py
```

This command reconstructs the same seed-2026, 168/72 train/test split used by
`it2_comparison.py`, fits the models using training data only, and verifies
the saved prediction CSV before plotting. It writes:

- `results/t1_it2_membership_functions.png`: six rule panels showing each
	Type-1 Gaussian curve, the corresponding IT2 lower/upper curves, and the
	shaded interval footprint for `delta=0.2`. The Type-1 curve is also the
	`delta=0` reference when the widths coincide.
- `results/t1_it2_heldout_predictions.png`: the true `sin(x)` function,
	held-out test targets, and Type-1/IT2 predictions on the same test inputs.

These figures explain the implemented formulas visually; they are synthetic
diagnostics and do not establish real-world superiority.

Run the exploratory delta sensitivity analysis with:

```powershell
d:\anaconda3\python.exe experiments\it2_delta_sensitivity.py
```

This evaluates `delta` values `0.0`, `0.1`, `0.2`, and `0.3` on the same
single test split and writes `results/it2_delta_sensitivity_metrics.csv`.
It is exploratory, not a statistically significant comparison: the test set
is reused across delta values, so it must not be treated as an untouched
final evaluation after selecting a delta.

The implemented formulas are:

```text
sigma_lo = sigma * (1 - delta)
sigma_hi = sigma * (1 + delta)
f_lo,k = product_j mu_lo,kj(x_j)
f_hi,k = product_j mu_hi,kj(x_j)
y = sum_k((f_lo,k + f_hi,k) * g_k(x)) /
	sum_k(f_lo,k + f_hi,k)
```

`IT2TSK.fit()` reuses Type-1 standardization, clustering, and least-squares
training code through inheritance, while dynamic dispatch makes its
consequent fit use IT2 effective strengths. The comparison uses one split,
one seed, and no statistical significance test; broader repeated-seed
evaluation remains to be done.

## Research showcase

The static dashboard lives in `index.html`, `styles.css`, and `app.js`. It
loads the existing CSV metrics at runtime and displays the existing PNG
figures; it does not change the fuzzy-system implementation or regenerate
results in the browser.

Start it from the project root on Windows with:

```powershell
python -m http.server 8000
```

Then open `http://localhost:8000`. Serving the folder is recommended because
browser security rules can block JavaScript CSV loading from a `file://` URL.
The dashboard reports the verified seed-2026 comparison, the exploratory
delta sensitivity table, and the 10-seed robustness aggregates. Its results
remain descriptive synthetic evidence, not a real-world superiority claim.