# Imbalanced classification and probability decisions

This lab supports NP-0341 through NP-0360 with original synthetic data and executable checks. Run `python imbalance_cases.py` from this directory. It creates `synthetic-fraud.csv` only when absent, executes all cases and writes `imbalance-verification.json`.

The fixture has 8,000 unique synthetic transactions across 500 repeated synthetic accounts: 3,000 train, 1,000 calibration, 1,500 validation, 1,500 test and 1,000 post-policy rows. Fitted features are `risk_signal`, `log_amount` and `velocity_24h`. Generator probability, label-flip indicator, future target, policy mechanism and identifiers are excluded from predictors. Splits are authored periods; no real fraud, customer, rupee-return or policy-effect claim is made.

The base examples use deterministic scikit-learn 1.9.0 configurations. Calibration fits a frozen 160-tree random forest on train rows and a sigmoid on a disjoint calibration set. Thresholds use validation and are evaluated once on test. A basic numeric-only SMOTE interpolation is implemented locally so every synthetic point's two minority parents can be checked against its fold boundary; this is a teaching implementation, not an implied dependency on imbalanced-learn or support for categorical sampling.

`verify()` currently enforces thirteen reference properties covering fold-local resampling, fixture grain, disjoint calibration roles, reliability-bin and queue denominators, capacity and precision constraints, account-cluster bootstrap replication, pure prior-shift construction, label-noise reconciliation, label maturity and the post-policy slice. Passing these checks establishes internal reproduction only. It is not editorial approval or deployment readiness.

Primary references: [scikit-learn probability calibration](https://scikit-learn.org/stable/modules/calibration.html), [CalibratedClassifierCV](https://scikit-learn.org/stable/modules/generated/sklearn.calibration.CalibratedClassifierCV.html), [precision-recall example](https://scikit-learn.org/stable/auto_examples/model_selection/plot_precision_recall.html), [classification metrics](https://scikit-learn.org/stable/api/sklearn.metrics.html), [cost-sensitive threshold tuning](https://scikit-learn.org/stable/auto_examples/model_selection/plot_cost_sensitive_learning.html), and the [imbalanced-learn sampler pipeline example](https://imbalanced-learn.org/stable/auto_examples/pipeline/plot_pipeline_classification.html).
