Skip to content

Metrics radtorch.metrics

ClassifierMetrics

ClassifierMetrics class a set of methods that enables quantiative evaluation of a trained image classifier performance.

Parameters:

Name Type Description Default
classifier ImageClassifier

trained ImageClassifier.

required
use_best_model bool

True to use the model with the lowest validation loss.

required
device str

Device to be used for training. Default: 'auto' which automtically detects GPU presence and uses it for feature extraction. Options: 'auto', 'cuda', 'cpu'.

'auto'

Methods

classification_report(self, subset='test')

Returns text report showing the main classification metrics.

Parameters:

Name Type Description Default
subset str

subset of the dataset to be used. This can be 'train', 'valid', or 'test'.

'test'

confusion_matrix(self, subset='test', figsize=(8, 6), cmap='Blues', percent=False)

Returns confusion matrix using target data. Code Adapted from https://github.com/DTrimarchi10/confusion_matrix/blob/master/cf_matrix.py

Parameters:

Name Type Description Default
subset str

subset of the dataset to be used. This can be 'train', 'valid', or 'test'.

'test'
figsize tuple

size of the displayed figure.

(8, 6)
cmap string

Name of Matplotlib color map to be used. See Matplotlib colormaps

'Blues'
percent bool

True to use percentages instead of real values.

False

Returns:

Type Description
figure

figure containing confusion matrix

get_predictions(self, subset)

new dataframe is created : self.pred_table, with important columns : label_id and pred_id

roc(self, subset='test', figure_size=(8, 6), plot=True)

Displays ROC of the trained classifier and returns ROC-AUC.

Parameters:

Name Type Description Default
subset str

subset of the dataset to be used. This can be 'train', 'valid', or 'test'.

'test'
figsize tuple

size of the displayed figure.

required
plot bool

True to display ROC.

True

Returns:

Type Description
float

float of ROC-AUC

Back to top