Comments (1)
Thanks for the post.
I'm not able to recreate the error. I've tried with synthetic data and your code works fine (see below). Can you give me some pointers to reproduce the problem ?
from sklearn.datasets import make_regression
from sklearn.model_selection import train_test_split
from catboost import CatBoostRegressor
import numpy as np
from deel.puncc.api.prediction import DualPredictor
from deel.puncc.regression import CQR
from deel.puncc.metrics import regression_mean_coverage, regression_sharpness
# Generate a random regression problem
X, y = make_regression(
n_samples=1000, n_features=4, n_informative=2, random_state=0, shuffle=False
)
# Split data into train and test
X, X_test, y, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
# Split train data into fit and calibration
X_fit, X_calib, y_fit, y_calib = train_test_split(
X, y, test_size=0.2, random_state=0
)
# reg_low catboost model
param = {
"loss_function": "Quantile:alpha=0.05",
"learning_rate": 0.4607417710785185,
"l2_leaf_reg": 0.03572230525884548,
"depth": 4,
"boosting_type": "Plain",
"bootstrap_type": "MVS",
"min_data_in_leaf": 8,
}
reg_low = CatBoostRegressor(**param)
# reg_high catboost parameters
param = {
"loss_function": "Quantile:alpha=0.95",
"learning_rate": 0.002097382718709981,
"l2_leaf_reg": 0.07411180923916862,
"depth": 1,
"boosting_type": "Plain",
"bootstrap_type": "Bayesian",
"min_data_in_leaf": 5,
"bagging_temperature": 9.119533192831474,
}
reg_high = CatBoostRegressor(**param)
# Dual predictor definition
predictor = DualPredictor(models=[reg_low, reg_high])
# Initialization of CQR conformalizer
crq = CQR(predictor)
# Fitting/calibration
crq.fit(X_fit=X_fit, y_fit=y_fit, X_calib=X_calib, y_calib=y_calib)
# Conformal prediction for alpha = 5%
y_pred, y_pred_lower, y_pred_upper = crq.predict(X_test, alpha=0.05)
# Results
coverage = regression_mean_coverage(y_test, y_pred_lower, y_pred_upper)
width = regression_sharpness(y_pred_lower=y_pred_lower,
y_pred_upper=y_pred_upper)
print(f"Marginal coverage: {np.round(coverage, 2)}")
print(f"Average width: {np.round(width, 2)}")
from puncc.
Related Issues (20)
- [Bug]: - Conflict between alpha_calib_check and weighted CP HOT 1
- Multivariate quantile
- Hypothesis testing correction
- Nonconformity scores for multivariate regression HOT 1
- Update calibrator for multivariate regression.
- Update CV+ calibration for conformal multiregression
- User friendly weight normalization
- Documentation for Inductive Conformal Anomaly Detection
- [Bug]: Makefile does not run properly when no "python" is installed on machine (but only "python3", for example)
- Possible to pass sklearn model (already trained) directly to SplitCP? HOT 1
- Is there an easy way to get the quantile that you use to build the interval? HOT 1
- Unexpected behaviour: SplitCP seems to ignore my pretrained model HOT 3
- Alpha_calib_check for multivariate regression
- [Feature]: prevent empty sets (keep conformal validity, lose upper bound tight coverage)
- ConformalPredictor extension for multivariate prediction
- API: conformalizing a pretrained underlying model with no splitter
- [Bug]: Instance variable is_trained is used incorrectly HOT 2
- All MAD predictions should be positive. HOT 5
- [Feature Request]: - EnbPI for any regression model HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from puncc.