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
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file independent_validation-0.1.2.tar.gz.
File metadata
- Download URL: independent_validation-0.1.2.tar.gz
- Upload date:
- Size: 194.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e151f77bab37d8cb980dc8d76cb8ce166bebbf9cb4fa1c3690c760561427c628
|
|
| MD5 |
2c0925d90e6e2209c16ab40496f8cc70
|
|
| BLAKE2b-256 |
e55d3b19ca932756b8bc59badc15502af849b32699c0c8e6212fae690408f221
|
File details
Details for the file independent_validation-0.1.2-py3-none-any.whl.
File metadata
- Download URL: independent_validation-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
080cdf0da1b932159113ce10dc6bef7137f251b4a29e828ebf19889e0594a456
|
|
| MD5 |
1f8e111a85abc80ba929aa3aa68c3827
|
|
| BLAKE2b-256 |
44d207f8b7dce67471c069501d40843eb5602f26ed3caa62ba340395cfcff139
|