probly.conformal_prediction.methods.cvplus

Cross-validation+ (CV+) implementation.

Classes

CVPlusClassifier(model_factory[, cv, ...])

CV+ Classifier (Defaults to 5-Fold).

CVPlusRegressor(model_factory[, cv, ...])

CV+ Regressor (Defaults to 5-Fold).

class probly.conformal_prediction.methods.cvplus.CVPlusClassifier(model_factory, cv=5, random_state=None, use_accretive=False, score_func=None)[source]

Bases: JackknifePlusClassifier

CV+ Classifier (Defaults to 5-Fold).

Parameters:
  • model_factory (Callable[[], Predictor])

  • cv (int)

  • random_state (int | None)

  • use_accretive (bool)

  • score_func (ScoreFunc | None)

static to_numpy(x)

Convert input to numpy array of floats.

Parameters:

x (Any)

Return type:

ndarray[Any, dtype[floating]]

calibrate(x_cal, y_cal, alpha)

Calibrate the Jackknife+ / CV+ predictor.

Parameters:
  • x_cal (Sequence[Any])

  • y_cal (Sequence[Any])

  • alpha (float)

Return type:

float

compute_scores(y_true, y_pred)

Compute nonconformity scores based on true and predicted values.

Parameters:
Return type:

ndarray[Any, dtype[floating]]

create_fold_assignments(x, y)

Create fold assignments for each sample based on the CV strategy.

Parameters:
Return type:

ndarray[Any, dtype[int64]]

get_aligned_predictions(x_test)

Get predictions from each fold model aligned to original data order.

Parameters:

x_test (ndarray[Any, dtype[_ScalarType_co]])

Return type:

ndarray[Any, dtype[floating]]

predict(x_test, alpha, probs=None)

Predict prediction sets for test data.

Parameters:
  • x_test (Sequence[Any])

  • alpha (float)

  • probs (Any | None)

Return type:

npt.NDArray[np.bool_]

predict_fold(model, x)

Predict using the given model on the provided data.

Parameters:
Return type:

npt.NDArray[np.floating]

class probly.conformal_prediction.methods.cvplus.CVPlusRegressor(model_factory, cv=5, random_state=None, score_func=None, interval_func=None)[source]

Bases: JackknifePlusRegressor

CV+ Regressor (Defaults to 5-Fold).

Parameters:
  • model_factory (Callable[[], Predictor])

  • cv (int)

  • random_state (int | None)

  • score_func (ScoreFunc | None)

  • interval_func (IntervalFunc | None)

static to_numpy(x)

Convert input to numpy array of floats.

Parameters:

x (Any)

Return type:

ndarray[Any, dtype[floating]]

calibrate(x_cal, y_cal, alpha)

Calibrate the Jackknife+ / CV+ predictor.

Parameters:
  • x_cal (Sequence[Any])

  • y_cal (Sequence[Any])

  • alpha (float)

Return type:

float

compute_scores(y_true, y_pred)

Compute nonconformity scores based on true and predicted values.

Parameters:
Return type:

ndarray[Any, dtype[floating]]

create_fold_assignments(x, y)

Create fold assignments for each sample based on the CV strategy.

Parameters:
Return type:

ndarray[Any, dtype[int64]]

get_aligned_predictions(x_test)

Get predictions from each fold model aligned to original data order.

Parameters:

x_test (ndarray[Any, dtype[_ScalarType_co]])

Return type:

ndarray[Any, dtype[floating]]

predict(x_test, alpha)

Predict prediction intervals for test data.

Parameters:
  • x_test (Sequence[Any])

  • alpha (float)

Return type:

npt.NDArray[np.floating]

predict_fold(model, x)

Predict using the given model on the provided data.

Parameters:
Return type:

npt.NDArray[np.floating]