Skip to content

Instantly share code, notes, and snippets.

View mjesusugarte's full-sized avatar

María Jesús Ugarte mjesusugarte

View GitHub Profile
def picp(real, lower, upper):
return ((real <= upper) & (real >= lower)).mean()
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)
target_column_name = 'charges'
train_percentage = 0.7
cal_percentage = 0.2
X = df.drop(columns=target_column_name).to_numpy()
Y = df[target_column_name].to_numpy()
n_total = X.shape[0]
n_train = int(train_percentage*n_total)
n_cal = int(cal_percentage*n_total) + n_train
train_data = X[:n_train, :]
train_target = Y[:n_train]