logging

logging

Logging utilities for conformalpy.

This module provides a configurable logger that integrates with the verbose parameter following scikit-learn conventions.

Verbosity Levels

0 : Silent (default) - Only warnings and errors 1 : Key events - Calibration start/end, prediction start/end 2 : Statistics - qhat, score distributions, set sizes 3 : Debug - Per-class breakdowns, timing information

Examples

>>> from conformalpy.logging import get_logger
>>> logger = get_logger("conformalpy", verbose=2)
>>> logger.info("Calibrating on 10000 samples")
[conformalpy] Calibrating on 10000 samples

Classes

Name Description
VerboseMixin Mixin class providing verbose logging support for estimators.

VerboseMixin

logging.VerboseMixin()

Mixin class providing verbose logging support for estimators.

Add this mixin to estimator classes to enable consistent verbose logging across the library.

Attributes

verbose : int

Verbosity level (0=silent, 1=key events, 2=stats, 3+=debug).

**_logger** : logging.Logger

Logger instance, created lazily on first access.

Examples

>>> class MyEstimator(VerboseMixin, BaseEstimator):
...     def __init__(self, verbose=0):
...         self.verbose = verbose
...
...     def fit(self, X, y):
...         self._log(1, f"Fitting on {len(y)} samples")
...         # ... fitting logic ...
...         self._log(2, f"Fitted, score_mean={np.mean(scores):.4f}")

Functions

Name Description
get_logger Get a logger configured based on verbose level.

get_logger

logging.get_logger(name='conformalpy', verbose=0, *, force_reconfigure=False)

Get a logger configured based on verbose level.

Parameters

name : str = "conformalpy"

Logger name. Use module-specific names for fine-grained control.

verbose : int = 0

Verbosity level: - 0: WARNING and above (silent for normal operation) - 1: INFO (key events) - 2: INFO (key events + statistics) - 3+: DEBUG (detailed per-class/per-sample info)

force_reconfigure : bool = False

If True, reconfigure existing handlers even if already set up. Useful when changing verbose level mid-session.

Returns

: logging.Logger

Configured logger instance.

Examples

>>> logger = get_logger("conformalpy.classifier", verbose=1)
>>> logger.info("Calibrating with 5000 samples")
[conformalpy.classifier] Calibrating with 5000 samples