pitci.lightgbm.LGBMBoosterAbsoluteErrorConformalPredictor¶
-
class
pitci.lightgbm.LGBMBoosterAbsoluteErrorConformalPredictor(model)[source]¶ Bases:
pitci.base.AbsoluteErrorConformalPredictorConformal interval predictor for an underlying
lgb.Boostermodel using non-scaled absolute error as the nonconformity measure.Class implements inductive conformal intervals where a calibration dataset is used to learn the information that is used when generating intervals for new instances.
The predictor outputs fixed width intervals for every new instance, there is no interval scaling implemented in this class.
The currently supported lightgbm objective functions, given the nonconformity measure that is based on absolute error, are defined in the
SUPPORTED_OBJECTIVESattribute.- Parameters
model (
lgb.Booster) – Underlyinglgb.Boostermodel to generate prediction intervals with.
-
__version__¶ The version of the
pitcipackage that generated the object.- Type
str
-
model¶ The underlying
lgb.Boostermodel passed in initialising the object.- Type
lgb.Booster
-
baseline_interval¶ The default or baseline conformal half interval width. Will be applied without modification to provide an interval for all new instances. Attribute is set when the
calibrate()method is run.- Type
float
-
alpha¶ The confidence level of the conformal intervals that will be produced. Attribute is set when the
calibrate()method is run.- Type
int or float
-
SUPPORTED_OBJECTIVES¶ Booster supported objectives. If a lgb.Booster with a non-supported objective is passed when initialising the class object an error will be raised.
- Type
list
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
alphais stored in an attribute of the same name.- Parameters
data (np.ndarray or pd.DataFrame) – 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 (np.ndarray or pd.DataFrame) – 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