nonconformist.acp.AggregatedCp

class nonconformist.acp.AggregatedCp(predictor, sampler=<nonconformist.acp.BootstrapSampler object>, aggregation_func=None, n_models=10)

Aggregated conformal predictor.

Combines multiple IcpClassifier or IcpRegressor predictors into an aggregated model.

Parameters:

predictor : object

Prototype conformal predictor (e.g. IcpClassifier or IcpRegressor) used for defining conformal predictors included in the aggregate model.

sampler : object

Sampler object used to generate training and calibration examples for the underlying conformal predictors.

aggregation_func : callable

Function used to aggregate the predictions of the underlying conformal predictors. Defaults to numpy.mean.

n_models : int

Number of models to aggregate.

References

[R12]Vovk, V. (2013). Cross-conformal predictors. Annals of Mathematics and Artificial Intelligence, 1-20.
[R22]Carlsson, L., Eklund, M., & Norinder, U. (2014). Aggregated Conformal Prediction. In Artificial Intelligence Applications and Innovations (pp. 231-240). Springer Berlin Heidelberg.

Attributes

predictor (object) Prototype conformal predictor.
predictors (list) List of underlying conformal predictors.
sampler (object) Sampler object used to generate training and calibration examples.
agg_func (callable) Function used to aggregate the predictions of the underlying conformal predictors
__init__(predictor, sampler=<nonconformist.acp.BootstrapSampler object>, aggregation_func=None, n_models=10)
fit(x, y)

Fit underlying conformal predictors.

Parameters:

x : numpy array of shape [n_samples, n_features]

Inputs of examples for fitting the underlying conformal predictors.

y : numpy array of shape [n_samples]

Outputs of examples for fitting the underlying conformal predictors.

Returns:

None

predict(x, significance=None)

Predict the output values for a set of input patterns.

Parameters:

x : numpy array of shape [n_samples, n_features]

Inputs of patters for which to predict output values.

significance : float or None

Significance level (maximum allowed error rate) of predictions. Should be a float between 0 and 1. If None, then the p-values are output rather than the predictions. Note: significance=None is applicable to classification problems only.

Returns:

p : numpy array of shape [n_samples, n_classes] or [n_samples, 2]

For classification problems: If significance is None, then p contains the p-values for each sample-class pair; if significance is a float between 0 and 1, then p is a boolean array denoting which labels are included in the prediction sets.

For regression problems: Prediction interval (minimum and maximum boundaries) for the set of test patterns.