Skip to main content

PredictionIntervals

PredictionIntervals(n_windows=2, h=1, method='conformal_distribution', scale_estimator=None)
Class for storing prediction intervals metadata information.

TransferConformal

TransferConformal(method='recalibrate', dre_estimator='logistic', weights=None, n_windows=None, step_size=None, cv=5, clip_quantile=0.99)
Predict-time configuration for transfer conformal prediction. Pass to MLForecast.predict(transfer_conformal=...) instead of the removed flat kwargs transfer_conformal_method, covariate_shift_weights, and dre_estimator. A plain string is shorthand for TransferConformal(method=<str>).

TransferConformal.validate

validate(pi)
Cross-validate against the fitted PredictionIntervals config.

estimate_density_ratio

estimate_density_ratio(source_features, target_features, estimator='logistic', cv=5, clip_quantile=0.99, return_target_weights=False)
Estimate w(x) = p_target(x) / p_source(x) for source domain points. Trains a binary classifier (source=0, target=1) on StandardScaler- normalised features and returns the odds ratio p(1|x) / p(0|x) for each source point. Parameters:
NameTypeDescriptionDefault
source_featuresndarrayFeature matrix for source-domain calibration points, shape (n_source, n_features).required
target_featuresndarrayFeature matrix for target-domain points, shape (n_target, n_features).required
estimatorstr"logistic" (default) or "gradient_boosting".‘logistic’
cvintNumber of stratified K-fold splits for cross-fitting (cv >= 2). Source weights are computed from out-of-fold predictions, reducing overfitting from in-sample scoring. cv=0 or cv=1 uses the original in-sample behavior. Defaults to 5.5
clip_quantileOptional[float]Clip source weights above this quantile of the computed weights to prevent extreme values. None disables clipping. Defaults to 0.99.0.99
return_target_weightsboolIf True, also return per-target-row weights (averaged across fold models when cv >= 2). Defaults to False.False
Returns:
TypeDescription
Union[ndarray, Tuple[ndarray, ndarray]]np.ndarray of shape (n_source,) if return_target_weights=False, else
Union[ndarray, Tuple[ndarray, ndarray]]a tuple (source_weights, target_weights) where target_weights has
Union[ndarray, Tuple[ndarray, ndarray]]shape (n_target,).