Skip to main content

IV is a Python package designed to assess the accuracy of machine learning classifiers by generating a full probability distribution of their performance. This method goes beyond traditional cross-validation by using an iterative process and Markov Chain Monte Carlo (MCMC) to estimate uncertainty. By only using samples for training after they have been tested alpha inflation is prevented.

Project description

IV: Independent Validation

IV is a Python package designed to assess the accuracy of machine learning classifiers by generating a full probability distribution of their performance. This method goes beyond traditional cross-validation by using an iterative process and Markov Chain Monte Carlo (MCMC) to estimate uncertainty. By only using samples for training after they have been tested alpha inflation is prevented.

Features

  • Independent Validation: Gradually expands the training set while recording prediction outcomes.
  • Posterior Sampling: Uses Metropolis-Hastings to compute posterior distributions of accuracy.
  • Custom Distribution Handling: Provides a custom histogram subclass for MAP estimation and distribution comparison.
  • Simple Interface: Use the one-function wrapper (independent_validation) for quick experiments.

Installation

  1. Clone the repository:
    git clone <repository-url>
    cd IV
    

2 Install dependencies: bash pip install numpy scipy scikit-learn matplotlib pandas pytest

Usage

An example of running the independent validation process with a classifier:

from independent_validation.one_func import independent_validation
from sklearn.linear_model import LogisticRegression
import numpy as np

# Generate or load your dataset
X = np.random.rand(100, 5)
y = np.random.randint(0, 2, size=100)

# Run independent validation
result = independent_validation(
    classifier=LogisticRegression(max_iter=200),
    X=X,
    y=y,
    key="acc",  # Use "acc" for accuracy or "bacc" for balanced accuracy
    n=50,
    output='map',
    plot=False,
    mcmc_num_samples=1000,
    mcmc_step_size=0.1,
    mcmc_burn_in=10000,
    mcmc_thin=50,
    mcmc_random_seed=42
)

print("MAP Accuracy:", result)

Project Structure

  • independent_validation/
    • iv_file.py — Core iterative validation process.
    • mcmc.py — Implements the Metropolis-Hastings MCMC sampler.
    • one_func.py — One-function interface for independent validation.
    • rv_hist_subclass.py — Custom histogram with extended functionality.
    • weighted_sum_distribution.py — Utility for combining probability distributions.
  • Tests & Demos:
    • combined_file.txt — Contains test descriptions and instructions.
    • _test_instructions.py — Provides detailed test cases and a demo using real data.

License

MIT License

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

independent_validation-0.1.1.tar.gz (194.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

independent_validation-0.1.1-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file independent_validation-0.1.1.tar.gz.

File metadata

  • Download URL: independent_validation-0.1.1.tar.gz
  • Upload date:
  • Size: 194.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for independent_validation-0.1.1.tar.gz
Algorithm Hash digest
SHA256 507add93581f31060612a9eba2e5794747cff11bd7bbd94ca5ba9a2577e3bbf5
MD5 95af56c3c5c5d7e016b6426a7642998d
BLAKE2b-256 c57abff53bd08c3800d40b53a7ae8ec5a8673af33fbd3d00c024225303dd81d4

See more details on using hashes here.

File details

Details for the file independent_validation-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for independent_validation-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d480ef48640d19a3e755b7cfadbb3b24dd6be5b2e559df49091d4dc607a1a0ef
MD5 b89e1628777293e48f45f0fe34f19f46
BLAKE2b-256 f66e4d5c146cc0a85a67254e488a6c8abdadcabfd5ffb283b0d87411f4d9c6a7

See more details on using hashes here.

Supported by

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