InfererenceReport

class pyinfer.InferenceReport(model: Callable, inputs: Any, n_seconds: Optional[Union[int, float]] = None, n_iterations: Optional[int] = None, exit_on_inputs_exhausted: bool = False, infer_failure_point: Optional[Union[int, float]] = None, model_name: Optional[str] = None, drop_stats: Optional[List[str]] = None)[source]

A model agnostic report of inference related stats for any callable model

__init__(model: Callable, inputs: Any, n_seconds: Optional[Union[int, float]] = None, n_iterations: Optional[int] = None, exit_on_inputs_exhausted: bool = False, infer_failure_point: Optional[Union[int, float]] = None, model_name: Optional[str] = None, drop_stats: Optional[List[str]] = None)[source]
Parameters
  • model (Callable) – The callable method or function for the model.

  • inputs (Any) – The input(s) parameters the model receives.

  • n_seconds (Union[int, float, None], optional) – Number of seconds to run model inferences. If this is None it is expected that n_iterations will be set. Defaults to None.

  • n_iterations (int, optional) – Number of iterations to run model inferences for. If this is None it is expected that n_seconds will be set. Defaults to None.

  • exit_on_inputs_exhausted (bool, optional) – If inputs are a iterable of inputs exit on completion. This feature is not yet implemented. Defaults to False.

  • infer_failure_point (Union[int, float, None], optional) – Time in seconds (int or float) at which an inference is to be considered a failure in the reporting stats. Defaults to None.

  • model_name (str, optional) – The name to give to the model for the report. Defaults to None.

  • drop_stats (List[str], optional) – List of keys to drop from the report. Defaults to None.

Raises
  • ModelIsNotCallableError – Will raise if the model provided is not callable.

  • MeasurementIntervalNotSetError – Will raise if neither n_seconds or n_iterations are set.

run(print_report: bool = True)dict[source]

Runs the inference report for self.model with input(s) self.inputs

Parameters
  • print_report (bool, optional) – If true a table representation of the report will be

  • to console. Defaults to True. (printed) –

Returns

A dictionary containing all the report stats created during the run.

Return type

dict

report(results_dict: dict)[source]

Prints a report to console based on the values found in results_dict

Parameters

results_dict (dict) – Dictionary containing compiled stats from a run.

plot(show: bool = True, save_location: Optional[str] = None)[source]

Creates a simple plot of self.runs. Plots run number on the x-axis and run time in milliseconds on the y-axis.

Parameters
  • show (bool, optional) – Whether to show the plot after calling method. Defaults to True.

  • save_location (str, optional) – Location to save plot at. If None the plot will not be saved. Defaults to None.

Raises
  • MatplotlibNotInstalledError – Raise if matplotlib is not installed in python environment.

  • ValueError – Raise if the runs have not yet been calculated but plot is called.