deep_learning
deep_learning
Deep Learning Integration for Conformal Prediction.
This module provides wrappers to use PyTorch and Keras/TensorFlow models with conformal prediction. Both are optional dependencies.
Provided classes:
TorchClassifierWrapper: Wraps PyTorch classifiers for use with ConformalClassifier.TorchRegressorWrapper: Wraps PyTorch regressors for use with ConformalRegressor.KerasClassifierWrapper: Wraps Keras classifiers for use with ConformalClassifier.KerasRegressorWrapper: Wraps Keras regressors for use with ConformalRegressor.
Provided functions:
is_torch_available: Check if PyTorch is installed.is_keras_available: Check if Keras/TensorFlow is installed.
Installation
PyTorch: pip install torch
Keras/TensorFlow: pip install tensorflow # or pip install keras
Examples
>>> from conformalpy.deep_learning import TorchClassifierWrapper
>>> from conformalpy.classifier import ConformalClassifier
>>>
>>> # Wrap your PyTorch model
>>> wrapped_model = TorchClassifierWrapper(pytorch_model)
>>>
>>> # Use with conformal prediction
>>> cc = ConformalClassifier(model=wrapped_model, alpha=0.1)
>>> cc.calibrate(X_calib, y_calib)
>>> pred_sets = cc.predict(X_test)