chemicalchecker.tool.targetmate.nonconformist.nc.MarginErrFunc

class MarginErrFunc[source]

Bases: ClassificationErrFunc

Calculates the margin error.

For each correct output in y, nonconformity is defined as

0.5 - \dfrac{\hat{P}(y_i | x) - max_{y \, != \, y_i} \hat{P}(y | x)}{2}

Methods

apply

Apply the nonconformity function.

apply(prediction, y)[source]

Apply the nonconformity function.

Parameters

predictionnumpy array of shape [n_samples, n_classes]

Class probability estimates for each sample.

ynumpy array of shape [n_samples]

True output labels of each sample.

Returns

ncnumpy array of shape [n_samples]

Nonconformity scores of the samples.