Skip to main content

Model Confidence Set

The model-confidence-set package provides a Python implementation of the Model Confidence Set (MCS) procedure (Hansen, Lunde, and Nason, 2011), a statistical method for comparing and selecting models based on their performance. It allows users to identify a set of models that are statistically indistinguishable from the best model, given a statistical confidence level.

This package

  • supports both stationary and block bootstrap methods.
  • implements two methods for p-value computation: relative and sequential.
  • optionally displays progress during computation.

Installation

To install model-confidence-set, simply use pip:

pip install model-confidence-set

Usage

To use the Model Confidence Set in your Python code, follow the example below:

import numpy as np
import pandas as pd
from model_confidence_set import ModelConfidenceSet

# Example losses matrix where rows are observations and columns are models
losses = np.random.rand(100, 5)  # 100 observations for 5 models

# Initialize the MCS procedure (5'000 bootstrap iterations, 5% confidence level)
mcs = ModelConfidenceSet(losses, n_boot=5000, alpha=0.05, show_progress=True)

# Compute the MCS
mcs.compute()

# Retrieve the results as a pandas DataFrame (use as_dataframe=False for a dict)
results = mcs.results()
print(results)

Parameters

  • losses: A 2D numpy.ndarray or pandas.DataFrame containing loss values of models. Rows correspond to observations, and columns correspond to different models.
  • n_boot: Number of bootstrap replications for computing p-values. Default is 5000.
  • alpha: Significance level for determining model confidence set. Default is 0.05.
  • block_len: The length of blocks for the block bootstrap. If None, it defaults to the square root of the number of observations.
  • bootstrap_variant: Specifies the bootstrap variant to use. Options are 'stationary' or 'block'. Default is 'stationary'.
  • method: The method used for p-value calculation. Options are 'R' for relative or 'SQ' for sequential. Default is 'R'.
  • show_progress: Whether to show a progress bar during bootstrap computations. Default is False.

Acknowledgments

This package draws inspiration from

Release files for model-confidence-set 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for model-confidence-set 0.1.3
File Size Uploaded
model_confidence_set-0.1.3.tar.gz 6.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for model-confidence-set 0.1.3
File Interpreter ABI Platform
model_confidence_set-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / model_confidence_set-0.1.3.tar.gz

Download URL model_confidence_set-0.1.3.tar.gz
Size 6.3 kB
Tags Source
SHA-256 checksum
How to use checksums
605f1498010fc71d6140eb86241290ec16b31b6131b37fbf0fb14b8fe1003009
BLAKE2b-256 checksum
How to use checksums
985947b2a644fa4be9b0e170f45c8dab31e15564633c7fc089d44f9e8d6f07f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / model_confidence_set-0.1.3-py3-none-any.whl

Download URL model_confidence_set-0.1.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f75fe29f5a25e45b5f49c2397803b5d7c4a117a64790ed5681194e973c04fef6
BLAKE2b-256 checksum
How to use checksums
d1180901711a99607621e2ea7997f4f23282423c10d533cae6f4ba38612a4dc7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page