lir.aggregation package
- class lir.aggregation.Aggregation[source]
Bases:
ABCBase representation of an aggregated data collection.
Other classes may extend from this class.
- close() None[source]
Finalize the aggregation; no more results will come in.
The close method is called at the end of gathering the aggregation(s) to ensure files are closed, buffers are cleared, or other things that need to finish / tear down.
- abstractmethod report(data: AggregationData) None[source]
Report that new results are available.
- Parameters:
data (AggregationData) – The aggregated data to be reported.
- class lir.aggregation.AggregationData(llrdata: LLRData, lrsystem: LRSystem, parameters: dict[str, HyperparameterOption | str], run_name: str, get_full_fit_lrsystem: Callable[[], LRSystem] | None = None)[source]
Bases:
NamedTupleRepresentation of aggregated data.
- get_full_fit_lrsystem
Optional callable that lazily provides a model fitted on full data (ignoring splits).
- Type:
Callable[[], LRSystem] | None
- parameters: dict[str, HyperparameterOption | str]
Alias for field number 2
- class lir.aggregation.CaseLLRToCsv(output_dir: Path, case_data_provider: DataProvider, filename: str = 'case_llr.csv')[source]
Bases:
AggregationAggregation that applies a full-data-fitted LR system to case data and stores LLRs as CSV.
- Parameters:
output_dir (Path) – Directory where the CSV file will be written.
case_data_provider (DataProvider) – Provider for the case data to apply the LR system to.
filename (str, optional) – Name of the output CSV file, by default ‘case_llr.csv’.
- report(data: AggregationData) None[source]
Apply the full-data-fitted LR system to the case data and store the resulting LLRs as CSV.
- Parameters:
data (AggregationData) – Aggregation data containing the fitted LR system and case data.
- class lir.aggregation.MetricsBarPlot(path: Path | None, metrics: Mapping[str, Callable[[LLRData], float | list[float]]])[source]
Bases:
AggregationGenerate a bar plot for metrics and runs.
The plot shows a bar for each LR-system run and metric combination.
Usage example in YAML:
output: metric_bars: metrics: - cllr - cllr_min
- Parameters:
path (Path) – The path to where the plot file is written.
metrics (Mapping[str, Callable]) – A mapping of metric names to functions that compute the values for the metrics.
- report(data: AggregationData) None[source]
Write the metrics to a plot.
- Parameters:
data (AggregationData) – The data for which to compute metrics.
- class lir.aggregation.PlotEach(plot_fn: Callable, plot_name: str, output_path: Path | None = None, **kwargs: Any)[source]
Bases:
AggregationAggregation that generates a plot for each call to
report().Repeated calls to
report()will result in separate plots.- Parameters:
plot_fn (Callable) – The plotting function to be used for generating plots.
plot_name (str) – The name of the plot.
output_path (Path | None, optional) – The directory where the plots will be saved. If None, plots are not saved.
**kwargs (Any) – Additional arguments to be passed to the plotting function.
- output_path
The directory where the plots will be saved. If None, plots are not saved.
- Type:
Path | None
- plot_fn
The plotting function to be used for generating plots.
- Type:
Callable
- report(data: AggregationData) None[source]
Plot the data when new results are available.
- Parameters:
data (AggregationData) – The aggregated data to be plotted.
- class lir.aggregation.SubsetAggregation(aggregation_methods: list[Aggregation], category_field: str)[source]
Bases:
AggregationAggregation method that manages data categorization.
A separate aggregation method is used for each category.
- Parameters:
aggregation_methods (list[Aggregation]) – A list of methods to aggregate results by category.
category_field (str) – The name of the category field.
- report(data: AggregationData) None[source]
Report that new results are available.
The data are categorized into subsets and forwarded to the actual aggregation method.
- Parameters:
data (AggregationData) – The aggregated data to be reported.
- class lir.aggregation.WriteMetricsToCsv(path: Path, columns: Mapping[str, Callable])[source]
Bases:
AggregationHelper class to write aggregated results to CSV file.
- Parameters:
path (Path) – The path to the CSV file where the metrics will be written.
columns (Mapping[str, Callable]) – A mapping of column names to metric functions that compute the values for those columns.
- report(data: AggregationData) None[source]
Write the metrics to CSV.
- Parameters:
data (AggregationData) – The aggregated data for which to compute and write the metrics.