mednet.engine.classify.saliency.utils

Common utilities for saliency generation and analysis tasks.

Functions

extract_statistics(data, index)

Extract all meaningful statistics from a reconciled statistics set.

make_histogram(name, values[, xlim, title])

Build an histogram of values.

make_plots(results, indexes[, xlim])

Plot histograms for a particular variable, across all datasets.

make_table(results, indexes, format_)

Summarize results obtained by interpretability or completeness analysis in a table.

mednet.engine.classify.saliency.utils.extract_statistics(data, index)[source]

Extract all meaningful statistics from a reconciled statistics set.

Parameters:
  • data (list[tuple[str, int, float, float, float]]) – A list of tuples each containing a sample name, target, and values produced by completeness and interpretability analysis.

  • index (int) – The index of the tuple contained in data that should be extracted.

Return type:

dict[str, Any]

Returns:

A dictionary containing the following elements:

  • values: A list of values corresponding to the index on the data

  • mean: The mean of the value listdir

  • stdev: The standard deviation of the value list

  • quartiles: The 25%, 50% (median), and 75% quartile of values

  • decreasing_scores: A list of sample names and labels in decreasing value.

mednet.engine.classify.saliency.utils.make_table(results, indexes, format_)[source]

Summarize results obtained by interpretability or completeness analysis in a table.

Parameters:
  • results (dict[str, list[Any]]) – The results to be summarized.

  • indexes (dict[int, str]) – A dictionary where keys are indexes in each sample of results, and values are a (possibly abbreviated) name to be used in table headers.

  • format – The table format.

Return type:

str

Returns:

A table, formatted following format_ and containing the various quartile informations for each split and metric.

mednet.engine.classify.saliency.utils.make_histogram(name, values, xlim=None, title=None)[source]

Build an histogram of values.

Parameters:
  • name (str) – Name of the variable to be histogrammed (will appear in the figure).

  • values (ndarray[tuple[int, ...], dtype[TypeVar(_ScalarType_co, bound= generic, covariant=True)]]) – Values to be histogrammed.

  • xlim (tuple[float, float] | None) – A tuple representing the X-axis maximum and minimum to plot. If not set, then use the bin boundaries.

  • title (None | str) – A title to set on the histogram.

Return type:

Figure

Returns:

A matplotlib figure containing the histogram.

mednet.engine.classify.saliency.utils.make_plots(results, indexes, xlim=None)[source]

Plot histograms for a particular variable, across all datasets.

Parameters:
  • results (dict[str, list[Any]]) – The results to be plotted.

  • indexes (dict[int, str]) – A dictionary where keys are indexes in each sample of results, and values are a (possibly abbreviated) name to be used in figure titles and axes.

  • xlim (tuple[float, float] | None) – Limits for histogram plotting.

Return type:

list[Figure]

Returns:

Matplotlib figures containing histograms for each dataset within results and named variables in indexes.