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
| def picp(real, lower, upper): | |
| return ((real <= upper) & (real >= lower)).mean() |
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) |
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
| 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] |