deel-ai / puncc

👋 Puncc is a python library for predictive uncertainty quantification using conformal prediction.
https://deel-ai.github.io/puncc/
280 stars 16 forks source link

Possible to pass sklearn model (already trained) directly to SplitCP? #34

Closed lmossina closed 9 months ago

lmossina commented 11 months ago

Module

Regression

Contact Details

No response

Feature Request

Would it be possible to avoid hand-wrapping my own pre-trained sklearn model with BasePredictor?

That is, pass directly my model to SplitCP, for instance?

See below for minimal example, which will raise an error for cp.fit(...) : AttributeError: 'LinearRegression' object has no attribute 'is_trained'

A minimal example

from deel.puncc.regression import SplitCP

mod = LinearRegression()
mod.fit(X_fit, y_fit)
cp = SplitCP(mod, train=False)
cp.fit( X_calib=X_cal, y_calib=y_cal)

Version

v0.9

Environment

- Python version: Python 3.10.12 via colab
lmossina commented 11 months ago

Maybe we could think of a way to make this import easier? (e.g. directly via deel.puncc.regression) For instance:

from deel.puncc.api.prediction import BasePredictor

To:

from deel.puncc.regression import SplitCP, BasePredictor

Put this import in __init__.py to make it visible when importing SplitCP? something of this kind