conformal.regression¶
Regression module contains methods for conformal regression.
Conformal regressors predict a range of values (not always a single value) under a given significance level (error rate). Every regressors works in combination with a nonconformity measure and on average predicts the correct value with the given error rate. Lower error rates result in narrower ranges of predicted values.
Structure:
- ConformalRegressor
- Inductive (
InductiveRegressor) - Cross (
CrossRegressor)
- Inductive (
-
class
conformal.regression.PredictionRegr(lo, hi)[source]¶ Bases:
objectConformal regression prediction object, which is produced by the
ConformalRegressor.predict()method.-
lo¶ Lowest value of the predicted range.
Type: float
-
hi¶ Highest value of the predicted range.
Type: float
Examples
>>> train, test = next(LOOSampler(Table('housing'))) >>> ccr = CrossRegressor(AbsError(LinearRegressionLearner()), 5, train) >>> prediction = ccr.predict(test[0], 0.1) >>> print(prediction.width())
-
__init__(lo, hi)[source]¶ Initialize the prediction.
Parameters: - lo (float) – Lowest value of the predicted range.
- hi (float) – Highest value of the predicted range.
-
-
class
conformal.regression.ConformalRegressor(nc_measure)[source]¶ Bases:
orangecontrib.conformal.base.ConformalPredictorBase class for conformal regression.
-
predict(example, eps)[source]¶ Compute a regression prediction object for a given example and significance level.
Function determines what is the
eps-th lowest nonconformity score and computes the range of values that would result in a lower or equal nonconformity. This inverse of the nonconformity score is computed by the nonconformity measure’scp.nonconformity.RegrNC.predict()function.Parameters: - example (Instance) – Orange row instance.
- eps (float) – Default significance level (error rate).
Returns: Regression prediction object.
Return type:
-
-
class
conformal.regression.TransductiveRegressor(nc_measure)[source]¶ Bases:
conformal.regression.ConformalRegressorTransductive regression. TODO
-
class
conformal.regression.InductiveRegressor(nc_measure, train=None, calibrate=None)[source]¶ Bases:
conformal.regression.ConformalRegressorInductive regression.
-
alpha¶ Nonconformity scores of the calibration instances. Computed by the
fit()method. Must be sorted in increasing order.
Examples
>>> train, test = next(LOOSampler(Table('housing'))) >>> train, calibrate = next(RandomSampler(train, 2, 1)) >>> icr = InductiveRegressor(AbsError(LinearRegressionLearner()), train, calibrate) >>> print(icr(test[0], 0.1))
-
__init__(nc_measure, train=None, calibrate=None)[source]¶ Initialize inductive regressor with a nonconformity measure, training set and calibration set. If present, fit the conformal regressor to the training set and compute the nonconformity scores of calibration set.
Parameters: - nc_measure (RegrNC) – Regression nonconformity measure.
- train (Optional[Table]) – Table of examples used as a training set.
- calibrate (Optional[Table]) – Table of examples used as a calibration set.
-
fit(train, calibrate)[source]¶ Fit the conformal regressor to the training set, compute and store sorted nonconformity scores (
alpha) on the calibration set and store the domain.Parameters: - train (Optional[Table]) – Table of examples used as a training set.
- calibrate (Optional[Table]) – Table of examples used as a calibration set.
-
-
class
conformal.regression.CrossRegressor(nc_measure, k, train=None)[source]¶ Bases:
conformal.regression.InductiveRegressorCross regression.
Examples
>>> train, test = next(LOOSampler(Table('housing'))) >>> ccr = CrossRegressor(AbsError(LinearRegressionLearner()), 4, train) >>> print(ccr(test[0], 0.1))
-
__init__(nc_measure, k, train=None)[source]¶ Initialize cross regressor with a nonconformity measure, number of folds and training set. If present, fit the conformal regressor to the training set.
Parameters: - nc_measure (RegrNC) – Regression nonconformity measure.
- k (int) – Number of folds.
- train (Optional[Table]) – Table of examples used as a training set.
-
fit(train)[source]¶ Fit the cross regressor to the training set. Split the training set into k folds for use as training and calibration set with an inductive regressor. Concatenate the computed nonconformity scores and store them (
InductiveRegressor.alpha).Parameters: train (Table) – Table of examples used as a training set.
-
-
class
conformal.regression.LOORegressor(nc_measure, train=None)[source]¶ Bases:
conformal.regression.CrossRegressorLeave-one-out regressor is a cross conformal regressor with the number of folds equal to the size of the training set.
Examples
>>> train, test = next(LOOSampler(Table('housing'))) >>> ccr = LOORegressor(AbsError(LinearRegressionLearner()), train) >>> print(ccr(test[0], 0.1))
-
__init__(nc_measure, train=None)[source]¶ Initialize cross regressor with a nonconformity measure, number of folds and training set. If present, fit the conformal regressor to the training set.
Parameters: - nc_measure (RegrNC) – Regression nonconformity measure.
- k (int) – Number of folds.
- train (Optional[Table]) – Table of examples used as a training set.
-
fit(train)[source]¶ Fit the cross regressor to the training set. Split the training set into k folds for use as training and calibration set with an inductive regressor. Concatenate the computed nonconformity scores and store them (
InductiveRegressor.alpha).Parameters: train (Table) – Table of examples used as a training set.
-