lir.lrsystems package
- class lir.lrsystems.BinaryLRSystem(pipeline: Transformer)[source]
Bases:
LRSystemLR system for binary data and a linear pipeline.
This may be used in specific source feature based LR systems.
In this strategy, a set of instances - captured within the feature vector X - and a set of (ground-truth) labels are used to train and afterward calculate corresponding LLR’s for given feature vectors.
- Parameters:
pipeline (Transformer) – Transformer pipeline used to fit and score instances.
- apply(instances: InstanceData) LLRData[source]
Use LR system to calculate the LLR data from the instance data.
Applies the specific source LR system on a set of instances, optionally with corresponding labels, and returns a representation of the calculated LLR data through the LLRData tuple.
The returned set of LLRs has the same order as the set of input instances, and the returned labels are unchanged from the input labels.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Likelihood-ratio data produced by applying the LR system.
- Return type:
- fit(instances: InstanceData) Self[source]
Fit the model on the given instance data.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This LR system instance after fitting the pipeline.
- Return type:
Self
- class lir.lrsystems.LRSystem[source]
Bases:
Transformer,ABCGeneral representation of an LR system.
- abstractmethod apply(instances: InstanceData) LLRData[source]
Use the LR system to calculate the LLR data from the instances.
Applies the LR system on a set of instances, optionally with corresponding labels, and returns a representation of the calculated LLR data through the LLRData tuple.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Likelihood-ratio data produced by applying the LR system.
- Return type:
- fit(instances: InstanceData) Self[source]
Fit the LR system on a set of features and corresponding labels.
The number of labels must be equal to the number of instances.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This LR system instance after optional fitting.
- Return type:
Self
- class lir.lrsystems.ScoreBasedSystem(preprocessing_pipeline: Transformer | None, pairing_function: PairingMethod, evaluation_pipeline: Transformer | None)[source]
Bases:
LRSystemProvide a representation of a common source, score-based LR system.
In this strategy, it is possible to prepare the data within a preprocessing_pipeline, create corresponding pairs of instances using the pairing_function and subsequently calculate scores as well as transform these scores to LLR’s in the final evaluation_pipeline.
- Parameters:
preprocessing_pipeline (Transformer | None) – Pipeline that preprocesses instances before pairing and evaluation.
pairing_function (PairingMethod) – Pairing method used to construct trace/reference comparisons.
evaluation_pipeline (Transformer | None) – Pipeline that converts scores to likelihood-ratio outputs.
- apply(instances: InstanceData) LLRData[source]
Use LR system to calculate LLR data from the instances.
Applies the score-based LR system on a set of instances, optionally with corresponding labels, and returns a representation of the calculated LLR data through the LLRData tuple.
The system takes instances as input, and calculates LLRs for pairs of instances. That means that there is a 2-1 relation between input and output data.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Likelihood-ratio data produced by applying the LR system.
- Return type:
- fit(instances: InstanceData) Self[source]
Fit the model on the instance data.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This LR system instance after fitting the evaluation pipeline.
- Return type:
Self
- class lir.lrsystems.TwoLevelSystem(preprocessing_pipeline: Transformer | None, pairing_function: PairingMethod, postprocessing_pipeline: Transformer | None, n_trace_instances: int, n_ref_instances: int)[source]
Bases:
LRSystemImplement two level model, common-source feature-based LR system architecture.
During the training phase, the system calculates statistics on the unpaired instances. On application, it calculates LRs for same-source and different-source pairs. Each side of the pair may consist of multiple instances.
See also: TwoLevelModelNormalKDE
- Parameters:
preprocessing_pipeline (Transformer | None) – Pipeline that preprocesses instances before pairing and evaluation.
pairing_function (PairingMethod) – Pairing method used to construct trace/reference comparisons.
postprocessing_pipeline (Transformer | None) – Value passed via
postprocessing_pipeline.n_trace_instances (int) – Number of trace instances to include in each pairing.
n_ref_instances (int) – Number of reference instances to include in each pairing.
- apply(instances: InstanceData) LLRData[source]
Apply this LR system on a set of instances and return LLR data.
Applies the two level LR system on a set of instances, and returns a representation of the calculated LLR data through the LLRData tuple.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Likelihood-ratio data produced by applying the LR system.
- Return type:
- fit(instances: InstanceData) Self[source]
Fit the model based on the instance data.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This LR system instance after fitting all components.
- Return type:
Self