Registry / ai-ml / iterative-stratification

iterative-stratification

JSON →
library0.1.9pypypi✓ verified 83d ago

Provides scikit-learn compatible cross-validators with stratification for multilabel data. Current version 0.1.9, release cadence is sporadic.

pip install iterative-stratification
INSTALL
IMPORT
SIG · ITERATIVE-STRATIFI
I
iterative-stratification
ai-mlpythonv0.1.9
Install
9.4s avg
Import
3486ms
Disk
280MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.1.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 9.4s · import 3.486s · 270MB
280MB installed
● package 280MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MultilabelStratifiedKFold
from iterstrat.ml_stratifiers import MultilabelStratifiedKFold
from iterative_stratification import ...
Package name is iterstrat, not iterative-stratification
MultilabelStratifiedShuffleSplit
from iterstrat.ml_stratifiers import MultilabelStratifiedShuffleSplit

Simple usage of MultilabelStratifiedKFold for multilabel classification.

import numpy as np from iterstrat.ml_stratifiers import MultilabelStratifiedKFold X = np.random.rand(20, 5) y = np.random.randint(0, 2, (20, 3)) # multilabel binary indicator matrix kf = MultilabelStratifiedKFold(n_splits=5, shuffle=True, random_state=42) for train_index, test_index in kf.split(X, y): print("Train:", train_index, "Test:", test_index)
Debug
Known issues
deprecatedscikit-learn 1.0 introduced extra parameter warnings; version 0.1.7+ handles these but if using older version, expect deprecation warnings.
fix
Upgrade to iterstrat 0.1.7 or higher.
affects: <0.1.7
gotchaThe package is imported as 'iterstrat', not 'iterative-stratification' or 'iterative_stratification'. Many users mistakenly use the PyPI name.
fix
Use 'from iterstrat.ml_stratifiers import ...'
affects: all
gotchaThe cross-validator expects y to be a binary indicator matrix (2d array of 0/1), not label indices. Use MultiLabelBinarizer from sklearn.preprocessing to convert.
fix
Ensure y is shape (n_samples, n_labels) with values 0 or 1.
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'iterative_stratification'
Incorrect import name; the actual module is 'iterstrat'.
fix
Change imports to 'from iterstrat.ml_stratifiers import MultilabelStratifiedKFold'
ValueError: The number of classes has to be greater than one
y provided as a 1d array or single-label; iterative stratification requires multilabel binary matrix.
fix
Convert labels to binary indicator matrix using sklearn.preprocessing.MultiLabelBinarizer.
DeprecationWarning: Passing 'n_splits' without 'n_splits' as a keyword argument is deprecated
Using older version (<0.1.7) with scikit-learn 1.0+.
fix
Upgrade to iterstrat >=0.1.7.
Upgrade
Version history
0.1.9latest on PyPI · released Oct 12, 2024
Audit
Dependencies
scikit-learnrequiredBase classes and compatibility
numpyrequiredArray operations
scipyrequiredSparse matrix support
Agent activity
10 hits · last 30 days
node
10
Resources
iterative-stratification — pip install iterative-stratification · libregistry