Data and machine learning#

These APIs preserve event-time and label-availability boundaries when building historical datasets, replaying runs, backtesting, or evaluating predictions.

Point-in-time datasets#

fraudtwin.ml.dataset.PointInTimeDataset

Stable rows and the manifest that describes their construction.

fraudtwin.ml.dataset.PointInTimeDatasetBuilder

Build historical features and labels using only available source data.

fraudtwin.ml.dataset.build_point_in_time_dataset

Convenience API for deterministic in-memory M9 construction.

fraudtwin.ml.dataset.write_point_in_time_dataset

Write the fixed-schema M9 Parquet table and its JSON manifest.

fraudtwin.ml.dataset.load_generated_run

Load one existing generated run without regenerating unrelated records.

Backtesting and prediction evaluation#

fraudtwin.ml.backtest.BacktestResult

Fold rows, metrics, and the immutable result manifest.

fraudtwin.ml.backtest.run_backtest

Build reproducible rolling folds from one existing generated history.

fraudtwin.ml.backtest.run_model_backtest

Run selected M19 model adapters over the existing M10 temporal folds.

fraudtwin.ml.backtest.write_backtest

Persist fold rows, metrics, and the append-only backtest manifest.

fraudtwin.ml.baseline.PredictionRecord

One external prediction at a point in time.

fraudtwin.ml.baseline.EvaluationResult

EvaluationResult(predictions: tuple[dict[str, typing.Any], ...], metrics: tuple[dict[str, typing.Any], ...], manifest: dict[str, typing.Any], model_artifacts: dict[str, bytes] | None = None)

fraudtwin.ml.baseline.evaluate_predictions

Evaluate external scores against a leakage-safe dataset.

fraudtwin.ml.baseline.train_baselines

Train configured deterministic baselines on train rows only.

Drift analysis#

Compare two point-in-time windows with deterministic PSI, Wasserstein, and Jensen–Shannon metrics. The report records window fingerprints and the label policy so an alert can be reproduced later.

fraudtwin.ml.drift.DriftConfig

Immutable policy controlling a drift comparison.

fraudtwin.ml.drift.DriftMetric

One measured drift value and its decision threshold.

fraudtwin.ml.drift.DriftReport

Reproducible comparison of two row windows.

fraudtwin.ml.drift.compare_windows

Compare two row windows using deterministic distribution metrics.

fraudtwin.ml.drift.compare_performance

Compare matching evaluation metrics under one threshold policy.