Evaluate performance

Created on Fri Nov 1 16:48:26 2019

@author: Lieke

scHPL.evaluate.confusion_matrix(true_labels, pred_labels)[source]

Construct a confusion matrix.

Parameters:
  • true_labels (array_like) – True labels of the dataset

  • pred_labels (array_like) – Predicted labels

Returns:

conf

Return type:

confusion matrix

scHPL.evaluate.heatmap(true_labels, pred_labels, order_rows: list | None = None, order_cols: list | None = None, transpose: bool = False, cmap: str = 'Reds', title: str | None = None, annot: bool = False, xlabel: str = 'Predicted labels', ylabel: str = 'True labels', shape=(10, 10), **kwargs)[source]

Plot a confusion matrix as a heatmap.

Parameters:
true_labels: array_like

True labels of the dataset

pred_labels: array_like

Predicted labels

order_rows: List = None

Order of the cell types (rows)

order_cols: List = None

Order of the cell types (cols)

transpose: Boolean = False

If True, the rows become the true labels instead of the columns.

cmapString = ‘reds’

Colormap to use. Can be any matplotlib colormap

titleString = None

Title of the plot.

annotBoolean = False

If true, the data value is added to each cell.

xlabelString = ‘Predicted labels’

Text of the x label

ylabelString = ‘True labels’

Text of the y label

shape(float, float) = (10,10)

Size of the plot

**kwargs :

Other keyword args for sns.heatmap().

:rtype: None.
scHPL.evaluate.hierarchical_F1(true_labels, pred_labels, tree: TreeNode)[source]

Calculate the hierarchical F1-score

Parameters:
  • true_labels (array_like) – True labels

  • pred_labels (array_like) – Predicted labels

  • tree (TreeNode) – Classification tree used to predict the labels

Returns:

hF1

Return type:

hierarchical F1-score