Created
March 5, 2021 12:57
-
-
Save mjesusugarte/993fba44f739e80d8cfac5e7941958b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from nonconformist.cp import IcpRegressor | |
from nonconformist.cp import IcpClassifier | |
from nonconformist.nc import NcFactory | |
import lightgbm as lgbm | |
# Create the underlying model | |
model = lgbm.LGBMRegressor() | |
# Default nonconformity measure | |
nc = NcFactory.create_nc(model) | |
# Inductive conformal regressor | |
icp = IcpRegressor(nc) | |
# Fit the ICP using the proper training set | |
icp.fit(x_train, y_train) | |
# Calibrate the ICP using the calibration set | |
icp.calibrate(x_cal, y_cal) | |
# Desired coverage | |
confidence = 0.8 | |
# Produce predictions for the test set | |
prediction = icp.predict(x_test, significance=(1-confidence)) | |
lower_b = prediction[:, 0] | |
upper_b = prediction[:, 1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment