pitci.base.ConformalPredictor

class pitci.base.ConformalPredictor(model)[source]

Bases: abc.ABC

Base class for all conformal predictors in the pitci package.

This class contains the generic methods that all child classes can inherit.

__version__

The version of the pitci package that generated the object.

Type

str

model

The underlying model passed in initialising the object.

Type

Any

abstract __init__(model)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(model)

Initialize self.

calibrate(data, response[, alpha])

Calibrate conformal intervals that will be applied to new instances when calling predict_with_interval.

predict_with_interval(data)

Generate predictions with conformal intervals using the underlying model.

calibrate(data, response, alpha=0.95)[source]

Calibrate conformal intervals that will be applied to new instances when calling predict_with_interval.

The value passed in alpha is stored in an attribute of the same name.

Parameters
  • data (Any) – Dataset to calibrate baselines on.

  • response (np.ndarray or pd.Series) – The associated response values for every record in data.

  • alpha (int or float, default = 0.95) – Confidence level for the intervals.

predict_with_interval(data)[source]

Generate predictions with conformal intervals using the underlying model.

Parameters

data (Any) – Dataset to generate predictions with intervals on.

Returns

predictions_with_interval – Array of predictions with intervals for each row in data. Output array will have 3 columns where the first is the lower interval, second are the predictions and the third is the upper interval.

Return type

np.ndarray