fraudtwin.ml.dataset#

Point-in-time dataset construction.

Status: Stable

Classes#

fraudtwin.ml.dataset.DatasetBuilder

alias of PointInTimeDatasetBuilder

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.

Functions#

fraudtwin.ml.dataset.build_dataset

Convenience API for deterministic in-memory M9 construction.

fraudtwin.ml.dataset.build_point_in_time_dataset

Convenience API for deterministic in-memory M9 construction.

fraudtwin.ml.dataset.load_generated_run

Load one existing generated run without regenerating unrelated records.

fraudtwin.ml.dataset.write_point_in_time_dataset

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

Constants and protocols#

Name

Reference

DATASET_SCHEMA

fraudtwin.ml.dataset.DATASET_SCHEMA

PIT_DATASET_SCHEMA

fraudtwin.ml.dataset.PIT_DATASET_SCHEMA

Detailed API#

Deterministic point-in-time training data construction.

The builder works on the existing in-memory M1-M8 records or on one generated run. It deliberately does not regenerate simulation state and does not add a feature-store or model-serving dependency.

fraudtwin.ml.dataset.DatasetBuilder[source]

alias of PointInTimeDatasetBuilder

class fraudtwin.ml.dataset.PointInTimeDataset(rows, manifest)[source][source]

Bases: object

Stable rows and the manifest that describes their construction.

Parameters:
  • rows (tuple[dict[str, Any], ...])

  • manifest (DatasetManifest)

property frame: DataFrame

Return the dataset as a frame with the stable output schema.

class fraudtwin.ml.dataset.PointInTimeDatasetBuilder(config, entities, behavior, source_manifest=None)[source][source]

Bases: object

Build historical features and labels using only available source data.

Parameters:
  • config (SimulationRunConfig)

  • entities (EntityDataset)

  • behavior (BehaviorDataset)

  • source_manifest (RunManifest | None)

build_rows(prediction_times=None)[source][source]

Build every eligible PIT row without applying M9 split boundaries.

M10 uses this shared row construction to assign several independent rolling folds while retaining the exact M9 availability logic.

Return type:

tuple[dict[str, Any], ...]

Parameters:

prediction_times (Mapping[str, datetime] | None)

build(prediction_times=None)[source][source]

Build rows in stable payment-ID order.

By default each payment is scored when its initial source event becomes available. Callers may provide a deterministic payment-to-prediction mapping for snapshot or delayed-prediction use cases.

Return type:

PointInTimeDataset

Parameters:

prediction_times (Mapping[str, datetime] | None)

fraudtwin.ml.dataset.build_point_in_time_dataset(config, entities, behavior, source_manifest=None, prediction_times=None)[source][source]

Convenience API for deterministic in-memory M9 construction.

Return type:

PointInTimeDataset

Parameters:
  • config (SimulationRunConfig)

  • entities (EntityDataset)

  • behavior (BehaviorDataset)

  • source_manifest (RunManifest | None)

  • prediction_times (Mapping[str, datetime] | None)

fraudtwin.ml.dataset.build_dataset(config, entities, behavior, source_manifest=None, prediction_times=None)[source]

Convenience API for deterministic in-memory M9 construction.

Return type:

PointInTimeDataset

Parameters:
  • config (SimulationRunConfig)

  • entities (EntityDataset)

  • behavior (BehaviorDataset)

  • source_manifest (RunManifest | None)

  • prediction_times (Mapping[str, datetime] | None)

fraudtwin.ml.dataset.load_generated_run(run_dir, *, allow_missing_delivery=False)[source][source]

Load one existing generated run without regenerating unrelated records.

Return type:

tuple[EntityDataset, BehaviorDataset, RunManifest]

Parameters:
  • run_dir (Path)

  • allow_missing_delivery (bool)

fraudtwin.ml.dataset.write_point_in_time_dataset(dataset, output_path, manifest_path=None)[source][source]

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

Return type:

tuple[Path, Path]

Parameters:
  • dataset (PointInTimeDataset)

  • output_path (Path)

  • manifest_path (Path | None)