Risk Control¶
Risk-controlling prediction methods.
Controllers¶
mapie.risk_control.MultiLabelClassificationController
¶
MultiLabelClassificationController(
predict_function: Callable[
[ArrayLike], Union[list[NDArray], NDArray]
],
risk: str = "recall",
method: Optional[str] = None,
target_level: Union[float, Iterable[float]] = 0.9,
confidence_level: Optional[float] = None,
rcps_bound: Optional[Union[str, None]] = None,
predict_params: ArrayLike = np.arange(0, 1, 0.01),
n_jobs: Optional[int] = None,
random_state: Optional[Union[int, RandomState]] = None,
verbose: int = 0,
)
Prediction sets for multilabel-classification.
This class implements two conformal prediction methods for estimating prediction sets for multilabel-classification. It guarantees (under the hypothesis of exchangeability) that a risk is at least 1 - alpha (alpha is a user-specified parameter). For now, we consider the recall as risk.
| PARAMETER | DESCRIPTION |
|---|---|
predict_function
|
predict_proba method of a fitted multi-label classifier.
It can return either:
- a list of arrays of length n_classes where each array is of shape
(n_samples, 2) with probabilities of the negative and positive class
(as output by
TYPE:
|
risk
|
The risk metric to control ("precision" or "recall"). The selected risk determines which conformal prediction methods are valid: - "precision" implies that method must be "ltt" - "recall" implies that method can be "crc" (default) or "rcps"
TYPE:
|
method
|
Method to use for the prediction . If
TYPE:
|
target_level
|
The minimum performance level for the metric. Must be between 0 and 1.
Can be a float or any iterable of floats.
By default
TYPE:
|
confidence_level
|
Can be a float, or
TYPE:
|
rcps_bound
|
Method used to compute the Upper Confidence Bound of the
average risk. Only necessary with the RCPS method. If provided when
using CRC or LTT it is ignored and a warning is raised. By default
TYPE:
|
predict_params
|
Array of parameters (thresholds λ) to consider for controlling the risk.
Defaults to np.arange(0, 1, 0.01). Length is used to set
TYPE:
|
n_jobs
|
Number of jobs for parallel processing using joblib
via the "locky" backend.
For this moment, parallel processing is disabled.
If By default
TYPE:
|
random_state
|
Pseudo random number generator state used for random uniform sampling to evaluate quantiles and prediction sets. Pass an int for reproducible output across multiple function calls. By default
TYPE:
|
verbose
|
The verbosity level, used with joblib for parallel processing.
For the moment, parallel processing is disabled.
The frequency of the messages increases with the verbosity level.
If it more than By default
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
valid_methods |
List of all valid methods. Either CRC or RCPS
TYPE:
|
valid_bounds |
List of all valid bounds computation for RCPS only.
TYPE:
|
n_predict_params |
Number of thresholds on which we compute the risk.
TYPE:
|
predict_params |
Array of parameters (noted λ in [3]) to consider for controlling the risk.
TYPE:
|
risks |
The risk for each observation for each threshold
TYPE:
|
r_hat |
Average risk for each predict_param
TYPE:
|
r_hat_plus |
Upper confidence bound for each predict_param, computed with different bounds. Only relevant when method="rcps".
TYPE:
|
best_predict_param |
Optimal threshold for a given alpha.
TYPE:
|
valid_index |
List of list of all index that satisfy fwer controlling. This attribute is computed when the user wants to control precision score. Only relevant when risk="precision" as it uses learn then test (ltt) procedure. Contains n_alpha lists.
TYPE:
|
valid_predict_params |
List of list of all thresholds that satisfy fwer controlling. This attribute is computed when the user wants to control precision score. Only relevant when risk="precision" as it uses learn then test (ltt) procedure. Contains n_alpha lists.
TYPE:
|
sigma_init |
First variance in the sigma_hat array. The default value is the same as in the paper implementation [1].
TYPE:
|
References
[1] Stephen Bates, Anastasios Angelopoulos, Lihua Lei, Jitendra Malik, and Michael I. Jordan. Distribution-free, risk-controlling prediction sets. CoRR, abs/2101.02703, 2021. URL https://arxiv.org/abs/2101.02703
[2] Angelopoulos, Anastasios N., Stephen, Bates, Adam, Fisch, Lihua, Lei, and Tal, Schuster. "Conformal Risk Control." (2022).
[3] Angelopoulos, A. N., Bates, S., Candès, E. J., Jordan, M. I., & Lei, L. (2021). Learn then test: "Calibrating predictive algorithms to achieve risk control".
Examples:
>>> import numpy as np
>>> from sklearn.multioutput import MultiOutputClassifier
>>> from sklearn.linear_model import LogisticRegression
>>> from mapie.risk_control import MultiLabelClassificationController
>>> X_toy = np.arange(4).reshape(-1, 1)
>>> y_toy = np.stack([[1, 0, 1], [1, 0, 0], [0, 1, 1], [0, 1, 0]])
>>> clf = MultiOutputClassifier(LogisticRegression()).fit(X_toy, y_toy)
>>> mapie_clf = MultiLabelClassificationController(predict_function=clf.predict_proba, target_level=0.7).calibrate(X_toy, y_toy)
>>> y_pi_mapie = mapie_clf.predict(X_toy)
>>> print(y_pi_mapie[:, :, 0])
[[ True False True]
[ True False True]
[False True True]
[False True False]]
Source code in mapie/risk_control/multi_label_classification.py
compute_risks
¶
compute_risks(
X: ArrayLike,
y: ArrayLike,
_refit: Optional[bool] = False,
) -> MultiLabelClassificationController
Fit the base estimator or use the fitted base estimator on batch data to compute risks. All the computed risks will be concatenated each time the compute_risks method is called.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
Training data.
TYPE:
|
y
|
Training labels.
TYPE:
|
_refit
|
Whether or not refit from scratch. By default False
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MultiLabelClassificationController
|
The model itself. |
Source code in mapie/risk_control/multi_label_classification.py
compute_best_predict_param
¶
Compute optimal predict_params based on the computed risks.
Source code in mapie/risk_control/multi_label_classification.py
calibrate
¶
Use the fitted base estimator to compute risks and predict_params. Note that for high dimensional data, you can instead use the compute_risks method to compute risks batch by batch, followed by compute_best_predict_param.
Parameters
X: ArrayLike of shape (n_samples, n_features) Training data.
y: NDArray of shape (n_samples, n_classes) Training labels.
Returns
MultiLabelClassificationController The model itself.
Source code in mapie/risk_control/multi_label_classification.py
predict
¶
Prediction sets on new samples based on the target risk level.
Prediction sets for a given alpha are deduced from the computed
risks.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray of shape (n_samples, n_classes, n_alpha)
|
|
Source code in mapie/risk_control/multi_label_classification.py
mapie.risk_control.SemanticSegmentationController
¶
SemanticSegmentationController(
predict_function: Callable[
[ArrayLike], Union[list[NDArray], NDArray]
],
risk: str = "recall",
method: Optional[str] = None,
target_level: Union[float, Iterable[float]] = 0.9,
confidence_level: Optional[float] = None,
rcps_bound: Optional[Union[str, None]] = None,
predict_params: ArrayLike = np.arange(0, 1, 0.01),
n_jobs: Optional[int] = None,
random_state: Optional[Union[int, RandomState]] = None,
verbose: int = 0,
)
Bases: MultiLabelClassificationController
Risk controller for semantic segmentation tasks, inheriting from MultiLabelClassificationController.
Source code in mapie/risk_control/multi_label_classification.py
predict
¶
Prediction sets on new samples based on the target risk level.
Prediction sets for a given alpha are deduced from the computed
risks.
| PARAMETER | DESCRIPTION |
|---|---|
X
|
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray of shape (n_samples, n_classes, n_alpha)
|
|
Source code in mapie/risk_control/semantic_segmentation.py
mapie.risk_control.BinaryClassificationController
¶
BinaryClassificationController(
predict_function: Callable[[ArrayLike], NDArray],
risk: Risk,
target_level: Union[float, List[float]],
confidence_level: float = 0.9,
best_predict_param_choice: Union[
Literal["auto"], Risk_str, BinaryClassificationRisk
] = "auto",
list_predict_params: NDArray = np.linspace(
0, 0.99, 100
),
fwer_method: Union[
FWER_METHODS, FWERProcedure
] = "bonferroni",
)
Controls the risk or performance of a binary classifier.
BinaryClassificationController finds the decision thresholds of a binary classifier that statistically guarantee a risk to be below a target level (the risk is "controlled"). It can be used to control a performance metric as well, such as the precision. In that case, the thresholds guarantee that the performance is above a target level.
Usage:
- Instantiate a BinaryClassificationController, providing the predict_proba method of your binary classifier
- Call the calibrate method to find the thresholds
- Use the predict method to predict using the best threshold
Note: for a given model, calibration dataset, target level, and confidence level, there may not be any threshold controlling the risk.
| PARAMETER | DESCRIPTION |
|---|---|
predict_function
|
predict_proba method of a fitted binary classifier. Its output signature must be of shape (len(X), 2). Or, in the general case of multi-dimensional parameters (thresholds),
a function that takes (X, *params) and outputs 0 or 1. This can be useful to e.g.,
ensemble multiple binary classifiers with different thresholds for each classifier.
In that case,
TYPE:
|
risk
|
The risk or performance metric to control. Valid options:
Can be a list of risks in the case of multi risk control.
TYPE:
|
target_level
|
The maximum risk level (or minimum performance level). Must be between 0 and 1. Can be a list of target levels in the case of multi risk control (length should match the length of the risks list).
TYPE:
|
confidence_level
|
The confidence level with which the risk (or performance) is controlled. Must be between 0 and 1. See the documentation for detailed explanations.
TYPE:
|
best_predict_param_choice
|
default="auto" How to select the best threshold from the valid thresholds that control the risk (or performance). The BinaryClassificationController will try to minimize (or maximize) a secondary objective. Valid options:
its string equivalent: "precision", "recall", "accuracy", "fpr" for false positive rate, or "predicted_positive_fraction". - A custom instance of BinaryClassificationRisk object
TYPE:
|
list_predict_params
|
The set of parameters (noted λ in [1]) to consider for controlling the risk (or performance).
When
TYPE:
|
fwer_method
|
Method used to control the family-wise error rate (FWER). Supported methods:
-
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
valid_predict_params |
The valid thresholds that control the risk (or performance). Use the calibrate method to compute these.
TYPE:
|
best_predict_param |
The best threshold that control the risk (or performance). It is a tuple if multi-dimensional parameters are used. Use the calibrate method to compute it.
TYPE:
|
p_values |
P-values associated with each tested parameter in
TYPE:
|
Examples:
>>> import numpy as np
>>> from sklearn.linear_model import LogisticRegression
>>> from sklearn.datasets import make_classification
>>> from sklearn.model_selection import train_test_split
>>> from mapie.risk_control import BinaryClassificationController, precision
>>> X, y = make_classification(
... n_features=2,
... n_redundant=0,
... n_informative=2,
... n_clusters_per_class=1,
... n_classes=2,
... random_state=42,
... class_sep=2.0
... )
>>> X_train, X_temp, y_train, y_temp = train_test_split(
... X, y, test_size=0.4, random_state=42
... )
>>> X_calib, X_test, y_calib, y_test = train_test_split(
... X_temp, y_temp, test_size=0.1, random_state=42
... )
>>> controller = BinaryClassificationController(
... predict_function=clf.predict_proba,
... risk=precision,
... target_level=0.6
... )
References
[1] Angelopoulos, Anastasios N., Stephen, Bates, Emmanuel J. Candès, et al. "Learn Then Test: Calibrating Predictive Algorithms to Achieve Risk Control." (2022)
Source code in mapie/risk_control/binary_classification.py
calibrate
¶
Calibrate the BinaryClassificationController. Sets attributes valid_predict_params and best_predict_param (if the risk or performance can be controlled at the target level).
| PARAMETER | DESCRIPTION |
|---|---|
X_calibrate
|
Features of the calibration set.
TYPE:
|
y_calibrate
|
Binary labels of the calibration set.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BinaryClassificationController
|
The calibrated controller instance. |
Notes
When using fwer_method="split_fixed_sequence",
the learning step must be performed separately on independent data:
- bcc.learn_fixed_sequence_order(X_learn, y_learn)
- bcc.calibrate(X_calibrate, y_calibrate)
Using the same data for both steps would invalidate guarantees.
Source code in mapie/risk_control/binary_classification.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
learn_fixed_sequence_order
¶
learn_fixed_sequence_order(
X_learn: ArrayLike,
y_learn: ArrayLike,
beta_grid: NDArray = np.logspace(-25, 0, 1000),
binary: bool = False,
) -> BinaryClassificationController
Learn an ordered sequence of prediction parameters for split fixed-sequence FWER control.
This method performs the learning step of split fixed-sequence testing.
It must be called before calibrate when fwer_method="split_fixed_sequence".
The data provided here must be independent from the calibration data used later in calibrate.
Using the same data would invalidate the statistical guarantees.
A typical workflow is to split your calibration dataset:
- one subset for learning the parameter order
- one subset for calibration
For each value in beta_grid, the parameter whose p-value vector is
closest to the constant vector beta is selected. Duplicate parameters are
removed while preserving order, yielding a deterministic testing sequence.
| PARAMETER | DESCRIPTION |
|---|---|
X_learn
|
Features used only to learn the parameter order.
TYPE:
|
y_learn
|
Binary labels associated with X_learn.
TYPE:
|
beta_grid
|
Grid of target p-values used to construct the ordering. Smaller values prioritize parameters with stronger evidence.
TYPE:
|
binary
|
Whether the loss associated with the controlled risk is binary.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
BinaryClassificationController
|
The controller instance with the learned sequence of ordered prediction parameters. |
Notes
This method does NOT perform risk control.
It only determines an order of parameters.
Statistical guarantees are provided later when calling calibrate.
Source code in mapie/risk_control/binary_classification.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
predict
¶
Predict using predict_function at the best threshold.
| PARAMETER | DESCRIPTION |
|---|---|
X_test
|
Features
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray
|
NDArray of shape (n_samples,) |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the method .calibrate was not called, or if no valid thresholds were found during calibration. |
Source code in mapie/risk_control/binary_classification.py
mapie.risk_control.BinaryClassificationRisk
¶
BinaryClassificationRisk(
risk_occurrence: Callable[
[NDArray[integer], NDArray[integer]], NDArray[bool_]
],
risk_condition: Callable[
[NDArray[integer], NDArray[integer]], NDArray[bool_]
],
higher_is_better: bool,
)
Define a risk (or a performance metric) to be used with the
BinaryClassificationController. Predefined instances are implemented,
see :data:mapie.risk_control.precision, :data:mapie.risk_control.recall,
:data:mapie.risk_control.accuracy,
:data:mapie.risk_control.false_positive_rate, and
:data:mapie.risk_control.predicted_positive_fraction.
Here, a binary classification risk (or performance) is defined by an occurrence and
a condition. Let's take the example of precision. Precision is the sum of true
positives over the total number of predicted positives. In other words, precision is
the average of correct predictions (occurrence) given that those predictions
are positive (condition). Programmatically,
precision = (sum(y_pred == y_true) if y_pred == 1)/sum(y_pred == 1).
Because precision is a performance metric rather than a risk, higher_is_better
must be set to True. See the implementation of precision in mapie.risk_control.
Note: any risk or performance metric that can be defined as
sum(occurrence if condition) / sum(condition) can be theoretically controlled
with the BinaryClassificationController, thanks to the LearnThenTest framework [1]
and the binary Hoeffding-Bentkus p-values implemented in MAPIE.
Note: by definition, the value of the risk (or performance metric) here is always between 0 and 1.
| PARAMETER | DESCRIPTION |
|---|---|
risk_occurrence
|
A function defining the occurrence of the risk for a given sample. Must take y_true and y_pred as input and return a boolean.
TYPE:
|
risk_condition
|
A function defining the condition of the risk for a given sample, Must take y_true and y_pred as input and return a boolean.
TYPE:
|
higher_is_better
|
Whether this BinaryClassificationRisk instance is a risk (higher_is_better=False) or a performance metric (higher_is_better=True).
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
higher_is_better |
See params.
TYPE:
|
References
[1] Angelopoulos, Anastasios N., Stephen, Bates, Emmanuel J. Candès, et al. "Learn Then Test: Calibrating Predictive Algorithms to Achieve Risk Control." (2022)
Source code in mapie/risk_control/risks.py
get_value_and_effective_sample_size
¶
Computes the value of a risk given an array of ground truth labels and the corresponding predictions. Also returns the number of samples used to compute that value.
That number can be different from the total number of samples. For example, in the case of precision, only the samples with positive predictions are used.
In the case of a performance metric, this function returns 1 - perf_value.
| PARAMETER | DESCRIPTION |
|---|---|
y_true
|
NDArray of ground truth labels, of shape (n_samples,), with values in {0, 1}
TYPE:
|
y_pred
|
NDArray of predictions, of shape (n_samples,), with values in {0, 1}
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tuple[float, int]
|
A tuple containing the value of the risk between 0 and 1, and the number of effective samples used to compute that value (between 1 and n_samples). In the case of a performance metric, this function returns 1 - perf_value. If the risk is not defined (condition never met), the value is set to 1, and the number of effective samples is set to -1. |
Source code in mapie/risk_control/risks.py
FWER Procedures¶
mapie.risk_control.FWERProcedure
¶
Bases: ABC
Base class for procedures controlling the Family-Wise Error Rate (FWER).
This class defines a unified interface for sequential multiple testing
procedures that allocate and update a global error budget delta
across a set of hypotheses.
Subclasses implement the strategy that determines:
- how the error budget is initialized,
- which hypothesis is tested next,
- how local significance levels are computed,
- how the state evolves after a rejection.
The main entry point is run which executes the procedure and returns
the indices of rejected hypotheses.
Methods to implement
_init_state(n_lambdas, delta) Initialize internal state.
_select_next_hypothesis(p_values) Return index of next hypothesis to test, or None if no test remains.
_local_significance_levels() Return current local significance levels.
_update_on_reject(hypothesis_index) Update state after a rejection.
run
¶
Execute the multiple testing procedure.
| PARAMETER | DESCRIPTION |
|---|---|
p_values
|
P-values associated with hypotheses.
TYPE:
|
delta
|
Target family-wise error rate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[int]
|
Sorted indices of rejected hypotheses. |
Source code in mapie/risk_control/fwer_control.py
mapie.risk_control.FWERBonferroniHolm
¶
Bases: FWERProcedure
Holm step-down procedure for controlling the FWER [1].
At each step, the hypothesis with the smallest p-value among the remaining ones is tested at level delta / k, where k is the number of hypotheses still active.
The procedure stops when the current hypothesis is not rejected.
Notes
This method strictly dominates Bonferroni in power while preserving strong FWER control.
[1] Holm, S. (1979). A simple sequentially rejective multiple test procedure. Scandinavian journal of statistics, 65-70.
mapie.risk_control.FWERFixedSequenceTesting
¶
Bases: FWERProcedure
Fixed Sequential Testing (ascending) procedure with multi-start for controlling the Family-Wise Error Rate (FWER) [1].
Hypotheses are assumed to be ordered according to a parameter grid such that rejection becomes progressively easier along the sequence.
If multiple starts are used, each start explores a disjoint segment of hypotheses. Starts falling inside already rejected regions are automatically discarded.
| PARAMETER | DESCRIPTION |
|---|---|
n_starts
|
Number of equally spaced starting points used in the multi-start procedure.
TYPE:
|
References
[1] P. Bauer, "Multiple testing in clinical trials," Statistics in Medicine, vol. 10, no. 6, pp. 871-890, 1991.
Source code in mapie/risk_control/fwer_control.py
mapie.risk_control.FWERBonferroniCorrection
¶
Bonferroni procedure for controlling the FWER [1].
Each hypothesis is tested independently at level delta / n_lambdas. The procedure stops as soon as one hypothesis is not rejected.
Notes
This is the simplest FWER-controlling method. It does not adapt to p-values and does not redistribute error budget after rejections.
[1] Bonferroni, C. E. (1936). Teoria statistica delle classi e calcolo delle probabilità.
run
¶
Execute the multiple testing procedure.
| PARAMETER | DESCRIPTION |
|---|---|
p_values
|
P-values associated with hypotheses.
TYPE:
|
delta
|
Target family-wise error rate.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
NDArray[int]
|
Sorted indices of rejected hypotheses. |
Source code in mapie/risk_control/fwer_control.py
Risk Functions¶
mapie.risk_control.accuracy
module-attribute
¶
accuracy = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: y_pred == y_true,
risk_condition=lambda y_true, y_pred: repeat(
True, len(y_true)
),
higher_is_better=True,
)
mapie.risk_control.false_positive_rate
module-attribute
¶
false_positive_rate = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: y_pred == 1,
risk_condition=lambda y_true, y_pred: y_true == 0,
higher_is_better=False,
)
mapie.risk_control.precision
module-attribute
¶
precision = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: (
ravel() == ravel()
),
risk_condition=lambda y_true, y_pred: ravel() == 1,
higher_is_better=True,
)
mapie.risk_control.recall
module-attribute
¶
recall = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: (
ravel() == ravel()
),
risk_condition=lambda y_true, y_pred: ravel() == 1,
higher_is_better=True,
)
mapie.risk_control.predicted_positive_fraction
module-attribute
¶
predicted_positive_fraction = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: y_pred == 1,
risk_condition=lambda y_true, y_pred: repeat(
True, len(y_true)
),
higher_is_better=False,
)
mapie.risk_control.positive_predictive_value
module-attribute
¶
mapie.risk_control.negative_predictive_value
module-attribute
¶
negative_predictive_value = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: y_pred == y_true,
risk_condition=lambda y_true, y_pred: y_pred == 0,
higher_is_better=True,
)
mapie.risk_control.abstention_rate
module-attribute
¶
abstention_rate = BinaryClassificationRisk(
risk_occurrence=lambda y_true, y_pred: isnan(y_pred),
risk_condition=lambda y_true, y_pred: repeat(
True, len(y_true)
),
higher_is_better=False,
)
mapie.risk_control.control_fwer
¶
control_fwer(
p_values: NDArray,
delta: float,
fwer_method: Union[
FWER_METHODS, FWERProcedure
] = "bonferroni",
) -> NDArray
Apply a Family-Wise Error Rate (FWER) control procedure.
This function applies a multiple testing correction to a collection
of p-values in order to control the family-wise error rate (FWER)
at level delta.
The correction method is selected via the fwer_method argument.
Supported methods are:
- "bonferroni": classical Bonferroni correction,
- "bonferroni_holm": Sequential Graphical Testing corresponding
to the Bonferroni-Holm procedure.
- "fixed_sequence": Fixed Sequence Testing (FST),
- "split_fixed_sequence": Split Fixed Sequence Testing (SFST).
- Custom procedures can also be implemented by subclassing FWERProcedure
and passing an instance to fwer_method.
| PARAMETER | DESCRIPTION |
|---|---|
p_values
|
P-values associated with each tested hypothesis.
TYPE:
|
delta
|
Target family-wise error rate. Must be in (0, 1].
TYPE:
|
fwer_method
|
FWER control strategy.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
valid_index
|
Sorted indices of hypotheses rejected under FWER control.
TYPE:
|
Notes
fwer_method="fixed_sequence" corresponds to the fixed sequence testing procedure with one start. However, users can use multi-start by instantiating FWERFixedSequenceTesting with any desired number of starts and passing the instance to control_fwer.
If fwer_method="split_fixed_sequence", this function behaves exactly as "fixed_sequence". The distinction exists only upstream, where the ordering of hypotheses may have been learned from separate data.