Registry /
ai-ml / iterative-stratification
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
muslpy 3.10–3.95 runs
build_error
glibcpy 3.10–3.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)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'iterative_stratification'
Incorrect import name; the actual module is 'iterstrat'.
fixChange 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.
fixConvert 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+.
fixUpgrade 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