Skip to main content

model-confidence-set 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.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_confidence_set-0.1.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

model_confidence_set-0.1.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file model_confidence_set-0.1.2.tar.gz.

File metadata

  • Download URL: model_confidence_set-0.1.2.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for model_confidence_set-0.1.2.tar.gz
Algorithm Hash digest
SHA256 327819fd360e46f16ab6b2fc49a7376042eb948035a353f97e69eaef37f7e520
MD5 79747dbd32394b733b50190e7b3b81c3
BLAKE2b-256 9d516eaad0149842769be08b20cc256f88c6fce2da8de07a220392b2ac8de97a

See more details on using hashes here.

File details

Details for the file model_confidence_set-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for model_confidence_set-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 81d5c15193d675507a483ce71227d36752862d774ec97d1446fc1aed886ef816
MD5 c4f3dd3dd06644b38dfcbbd4fada68a0
BLAKE2b-256 3bfe680f704b7c4f83a8177b49615af6873c144968fb7daa311b51d44f93df80

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page