deeplc.calibration
Calibration utilities.
- class deeplc.calibration.Calibration(*args, **kwargs)
Bases:
ABCInitialize the calibration model.
- abstractmethod fit(target, source)
Fit the calibration from source to target.
- exception deeplc.calibration.CalibrationError
Bases:
DeepLCErrorRaised when calibration fails.
- class deeplc.calibration.IdentityCalibration
Bases:
CalibrationInitialize IdentityCalibration.
- fit(target, source)
No-op; identity calibration does not fit.
- class deeplc.calibration.MultiHeadCalibration(*args, **kwargs)
Bases:
ABCInitialize the calibration model.
- selected_model_head: int
The best-correlating head, set by
fit. Meaningful for every implementer, includingMultiHeadRidgeCalibration, which reports the single best head even though it fits on several.
- abstractmethod fit(target, source)
Fit the calibration from the source matrix to target.
- abstractmethod transform(source)
Transform the source matrix into the calibrated target space.
- disagreement(source)
Per-input uncertainty score, or None when the calibration has none.
A calibration that combines several estimates of the same retention time can report how far they lie apart for each input, which
deeplc.report.prediction_report()uses to scale its prediction intervals per peptide. One fitted on a single head has no spread to report and keeps this default.
- class deeplc.calibration.MultiHeadPiecewiseLinearCalibration(number_of_splits=10, extrapolate=True, use_median=False, min_samples_per_segment=20)
Bases:
_SingleHeadCalibrationPiece-wise linear calibration on whichever head correlates best with the reference.
- Parameters:
number_of_splits (int) – Number of segments to split the source value range into. More segments allow more flexibility but may lead to overfitting.
extrapolate (bool) – If True, allows extrapolation outside the fitted source value range. If False, clips input values to the fitted range.
use_median (bool) – If True, uses the median of each segment to define anchors. If False, uses the mean.
min_samples_per_segment (int) – Minimum number of samples required for a segment to contribute an anchor. Segments with fewer samples are skipped, which helps avoid unstable anchors in sparse regions when using many splits.
- class deeplc.calibration.MultiHeadRidgeCalibration(n_heads=80, alphas=None)
Bases:
MultiHeadCalibrationInitialize MultiHeadRidgeCalibration.
- Parameters:
n_heads (int)
alphas (np.ndarray | None)
- fit(target, source)
Select, calibrate and weight the heads.
- transform(source)
Calibrate predictions of the model this calibration was fitted with.
- disagreement(source)
Report how far the combined setup heads lie apart for each input, in reference units.
Every selected head estimates the retention time of the same peptide, so the spread of those estimates, weighted by the ridge weight each head received, is an uncertainty that varies from peptide to peptide rather than only along the gradient. Returns None while the calibration is unfitted or combines a single head, which carries no spread.
- class deeplc.calibration.MultiHeadSplineCalibration
Bases:
_SingleHeadCalibrationInitialize MultiHeadSplineCalibration.
- class deeplc.calibration.PiecewiseLinearCalibration(number_of_splits=10, extrapolate=True, use_median=False, min_samples_per_segment=20)
Bases:
CalibrationPiece-wise linear calibration based on per-split anchors.
- Parameters:
number_of_splits (int) – Number of segments to split the source value range into. More segments allow more flexibility but may lead to overfitting.
extrapolate (bool) – If True, allows extrapolation outside the fitted source value range. If False, clips input values to the fitted range.
use_median (bool) – If True, uses the median of each segment to define anchors. If False, uses the mean.
min_samples_per_segment (int) – Minimum number of samples required for a segment to contribute an anchor. Segments with fewer samples are skipped, which helps avoid unstable anchors in sparse regions when using many splits.
- fit(target, source)
Fit a piece-wise linear model mapping source to target values.
- transform(source)
Transform source values using the fitted piece-wise linear model.
- class deeplc.calibration.SplineTransformerCalibration
Bases:
CalibrationInitialize SplineTransformerCalibration.
- fit(target, source)
Fit a spline-based model mapping source to target values.
- deeplc.calibration.upgrade_calibration(calibration)
Wrap a naive, single-series calibration in its matching
MultiHeadCalibration.A
MultiHeadCalibrationinstance is returned unchanged. A naiveCalibrationmust not be fitted yet: a fitted instance carries no record of which head it was fit on, so there is nothing to wrap it around.- Parameters:
calibration (Calibration | MultiHeadCalibration) – The calibration to wrap, naive or already multi-head.
- Returns:
calibrationitself if it already is one, otherwise a new wrapper around it.- Return type: