pysad.transform.probability_calibration.ConformalProbabilityCalibrator

class pysad.transform.probability_calibration.ConformalProbabilityCalibrator(windowed=True, window_size=300)[source]

This class provides an interface to convert the scores into probabilities through conformal prediction. Note that [BLF13] fits conformal calibration to already fitted samples’ scores by the model whereas [BIBBN17] fits the conformal calibration to some window of previous samples that are just before the target instance. This calibrator transforms by providing target score divided by the number of instances that are fitted before to this calibrator as transformation result.

Args:

windowed (bool): Whether the probability calibrator is windowed so that forget scores that are older than window_size. window_size (int): The size of window for running average and std. Ignored if running_statistics parameter is False.

Methods

__init__([windowed, window_size])

fit(scores)

Shortcut method that iteratively applies fit_partial to all instances in order.

fit_partial(score)

Fits particular (next) timestep's score to train the postprocessor.

fit_transform(scores)

Shortcut method that iteratively applies fit_transform_partial to all instances in order.

fit_transform_partial(score)

Shortcut method that iteratively applies fit_partial and transform_partial, respectively.

transform(scores)

Shortcut method that iteratively applies transform_partial to all instances in order.

transform_partial(score)

Transforms given score.

fit(scores)

Shortcut method that iteratively applies fit_partial to all instances in order.

Parameters:

shape (np.float64 array of) – Input scores.

Returns:

self.

Return type:

object

fit_partial(score)[source]

Fits particular (next) timestep’s score to train the postprocessor.

Parameters:

score (float) – Input score.

Returns:

self.

Return type:

object

fit_transform(scores)

Shortcut method that iteratively applies fit_transform_partial to all instances in order.

Parameters:

shape (np.float64 array of) – Input scores.

Returns:

Processed scores.

Return type:

np.float64 array of shape (num_instances,)

fit_transform_partial(score)

Shortcut method that iteratively applies fit_partial and transform_partial, respectively.

Parameters:

score (float) – Input score.

Returns:

Processed score.

Return type:

float

transform(scores)

Shortcut method that iteratively applies transform_partial to all instances in order.

Parameters:

shape (np.float64 array of) – Input scores.

Returns:

Processed scores.

Return type:

np.float64 array of shape (num_instances,)

transform_partial(score)[source]

Transforms given score.

Parameters:

score (float) – Input score.

Returns:

Processed score.

Return type:

float