classifier.JackknifePlusClassifier
classifier.JackknifePlusClassifier(
base_estimator=None,
alpha=0.1,
nonconformity_function=None,
cv=None,
random_state=None,
)Cross-conformal classifier (jackknife+ / CV+ for classification).
Uses leave-one-out (cv=None) or K-fold cross-validation to compute held-out nonconformity scores, retains the per-fold estimators, and builds prediction sets at test time using Vovk’s cross-conformal p-values.
Parameters
base_estimator : estimator = None-
Base classifier implementing
fit()andpredict_proba(). alpha : float = 0.1-
Significance level. Labels with p-value strictly greater than
alphaare included in the prediction set. nonconformity_function : callable = None-
Function with signature
(y_true, y_prob) -> scores. cv : int or None = None-
Cross-validation strategy: -
None: Leave-one-out (nmodel fits). -int: K-fold CV (cvmodel fits). random_state : int = None-
Random seed for K-fold shuffling. Ignored when
cv is None.
Attributes
estimators_ : list of estimators-
Per-fold fitted models.
fold_assignment_ : ndarray of shape (n_samples,)-
Index into
estimators_of the held-out estimator for each training sample. calibration_scores_ : ndarray of shape (n_samples,)-
Nonconformity scores from held-out predictions.
classes_ : ndarray-
Unique class labels (sorted).
n_classes_ : int-
Number of classes.
model_ : estimator-
Base estimator refit on the full training data. Used by
predict_proba()andpredict_top_k(); not used to build prediction sets. qhat_ : float-
Backwards-compatible scalar threshold computed from
calibration_scores_using the split-conformal formula⌈(n+1)(1−α)⌉/nquantile (withmethod='higher'). Reported for inspection only; not used bypredict().
See Also
ConformalClassifier : Split conformal classifier (requires calibration set). CVPlusClassifier : Same algorithm; alternate name kept for parity with the regression API.
Methods
| Name | Description |
|---|---|
| fit | Fit the cross-conformal classifier. |
| predict | Cross-conformal prediction sets. |
| predict_proba | Class probabilities from the model refit on the full training set. |
| predict_top_k | Top-K prediction sets (no coverage guarantee). |
| score | Empirical coverage on test data. |
fit
classifier.JackknifePlusClassifier.fit(X, y)Fit the cross-conformal classifier.
Parameters
X : array-like of shape (n_samples, n_features)y : array-like of shape (n_samples,)
Returns
self : JackknifePlusClassifier
predict
classifier.JackknifePlusClassifier.predict(X, *, alpha=None)Cross-conformal prediction sets.
Parameters
X : array-like of shape (n_samples, n_features)alpha : float, list of float, or None = None-
Significance level(s). If
None, usesself.alpha. If a scalar, returnslist[list[int]]. If array-like, returns a boolean array of shape(n_samples, n_classes, n_alphas).
Returns
: list of list of int or ndarray
predict_proba
classifier.JackknifePlusClassifier.predict_proba(X)Class probabilities from the model refit on the full training set.
predict_top_k
classifier.JackknifePlusClassifier.predict_top_k(X, k)Top-K prediction sets (no coverage guarantee).
Returns the k most likely classes per sample, ordered by decreasing probability under the model refit on the full training data. This bypasses the cross-conformal machinery; coverage guarantees do not apply.
score
classifier.JackknifePlusClassifier.score(X, y)Empirical coverage on test data.