Skip to content

ml_reports

qoa4ml.reports.ml_reports

Classes

MLReport

MLReport manages the reporting of machine learning metrics and inference data.

Parameters:

Name Type Description Default
client_config
ClientInfo

Configuration settings related to the client.

required

Attributes:

Name Type Description
client_config ClientInfo

A deep copy of the client configuration.

init_time float

The initialization time of the report.

previous_report list[GeneralMlInferenceReport]

A list of previously processed reports.

report GeneralMlInferenceReport

The current state of the report.

Methods:

Name Description
reset

Reset the report to an initial state.

combine_stage_report

Combine metrics from the current and previous stage reports.

process_previous_report

Process and incorporate a previous report.

observe_metric

Observe and record a metric.

observe_inference

Observe and record inference data.

observe_inference_metric

Observe and record an inference-specific metric.

generate_report

Generate the report and optionally reset the current report state.

Functions
__init__(client_config)

Initialize an instance of MLReport.

Parameters:

Name Type Description Default
client_config ClientInfo

Configuration settings related to the client.

required
combine_stage_report(current_stage_report, previous_stage_report)

Combine metrics from the current and previous stage reports.

Parameters:

Name Type Description Default
current_stage_report dict

The current stage report containing metrics.

required
previous_stage_report dict

The previous stage report containing metrics.

required

Returns:

Type Description
dict

Combined stage report containing metrics from both reports.

generate_report(reset=True, corr_id=None)

Generate the report and optionally reset the current report state.

Parameters:

Name Type Description Default
reset bool

Whether to reset the report state after generating the report, default is True.

True
corr_id Optional[str]

Correlation ID for the report, default is None.

None

Returns:

Type Description
BaseReport

The generated report.

Notes
  • Adds metadata such as client configuration, timestamp, and runtime to the report.
  • Deep copies the current state of the report before optionally resetting it.
observe_inference(inference_value)

Observe and record inference data.

Parameters:

Name Type Description Default
inference_value Any

The value of the inference to be recorded.

required
Notes
  • Raises a warning if inference data already exists for the current instance.
observe_inference_metric(metric)

Observe and record an inference-specific metric.

Parameters:

Name Type Description Default
metric Metric

The inference-specific metric to be recorded.

required
observe_metric(report_type, stage, metric)

Observe and record a metric.

Parameters:

Name Type Description Default
report_type ReportTypeEnum

The type of report being generated.

required
stage str

The stage of the process in which the metric is recorded.

required
metric Metric

The metric to be recorded.

required

Raises:

Type Description
ValueError

If the stage name is empty or the report type is not handled.

process_previous_report(previous_report_dict)

Process and incorporate a previous report.

Parameters:

Name Type Description Default
previous_report_dict dict

Dictionary representation of a previous report.

required
Notes
  • Service quality, data quality, and ML inference reports are combined with the current report.
reset()

Reset the report to an initial state.

Notes
  • This method initializes a new report model and clears the list of previous reports.