fraudtwin.label_observation#

Label availability and observation histories.

Status: Stable

Functions#

fraudtwin.label_observation.apply_label_observation

Apply a deterministic observation policy without mutating source records.

fraudtwin.label_observation.reconstruct_label_history

Return the immutable versions in validated chronological order.

fraudtwin.label_observation.resolve_label_observation

Return the validated M17 policy from either a run or policy config.

fraudtwin.label_observation.validate_label_observation

Validate references, ordering, and immutable truth invariants.

fraudtwin.label_observation.visible_label_at

Resolve the latest label version available at a prediction timestamp.

Detailed API#

Deterministic, append-only observation of latent fraud labels.

fraudtwin.label_observation.apply_label_observation(config, fraud_records, payments, *, customers=(), alerts=(), seed=None, simulation_run_id=None)[source][source]

Apply a deterministic observation policy without mutating source records.

Return type:

tuple[tuple[LabelObservation, ...], tuple[FinalObservedLabel, ...]]

Parameters:
  • config (SimulationRunConfig | LabelObservationConfig)

  • fraud_records (Iterable[FraudRecord])

  • payments (Iterable[Payment])

  • customers (Iterable[Customer])

  • alerts (Iterable[FraudAlert])

  • seed (int | None)

  • simulation_run_id (str | None)

fraudtwin.label_observation.reconstruct_label_history(observation)[source][source]

Return the immutable versions in validated chronological order.

Return type:

tuple[LabelVersion, ...]

Parameters:

observation (LabelObservation)

fraudtwin.label_observation.resolve_label_observation(config)[source][source]

Return the validated M17 policy from either a run or policy config.

Return type:

LabelObservationConfig

Parameters:

config (SimulationRunConfig | LabelObservationConfig)

fraudtwin.label_observation.validate_label_observation(observations)[source][source]

Validate references, ordering, and immutable truth invariants.

Return type:

None

Parameters:

observations (Iterable[LabelObservation])

fraudtwin.label_observation.visible_label_at(observation, prediction_time)[source][source]

Resolve the latest label version available at a prediction timestamp.

Return type:

LabelVersion

Parameters:
  • observation (LabelObservation)

  • prediction_time (datetime)