Registry / ai-ml / forestci

forestci

JSON →
library0.7pypypiunverified

forestci provides confidence intervals for random forest predictions using the infinitesimal jackknife method. It supports scikit-learn's RandomForestClassifier, RandomForestRegressor, ExtraTreesClassifier, and ExtraTreesRegressor. Version 0.7 includes bug fixes and improved documentation, with no breaking changes from 0.6. The library is stable but released infrequently.

pip install forestci
INSTALL
IMPORT
SIG · FORESTCI
F
forestci
ai-mlpythonv0.7
Install
10.6s avg
Import
—
Disk
281MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.7 · 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.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 10.6s · import 0.000s · 271MB
281MB installed
● package 281MB
Code
Verified usage

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

calc_inference
✓ from forestci import calc_inference
main function for computing confidence intervals
random_forest_error
✓ from forestci import random_forest_error
computes bias-corrected error variance
forestci
✓ import forestci
✗ from forestci import forestci
forestci is a module, not a function; do not import as a submodule

Compute confidence intervals for RandomForestRegressor predictions using the infinitesimal jackknife.

from sklearn.ensemble import RandomForestRegressor from sklearn.datasets import make_regression from forestci import random_forest_error import numpy as np X, y = make_regression(n_samples=100, n_features=4, noise=0.1, random_state=42) rf = RandomForestRegressor(n_estimators=100, random_state=42) rf.fit(X, y) pred = rf.predict(X) error_var = random_forest_error(rf, X, X) # 95% confidence interval ci = 1.96 * np.sqrt(error_var) print(ci[:5])
Debug
Known issues
gotcharandom_forest_error requires the training data (X_train) to compute the inbag matrix. If you pass the same data for prediction, ensure it is the training set.
fix
Use X_train as the 'inbag' argument or pass the training data explicitly.
affects: all
gotchacalc_inference (formerly calc_corr) has been deprecated. Use random_forest_error for variance estimation and then compute confidence intervals manually.
fix
Replace calc_inference with random_forest_error(
    rf, X_test, X_train
) + manual CI computation.
affects: >=0.6
gotchaIn version 0.7, the random_forest_error function may raise AttributeError if the forest estimator doesn't have estimators_samples_ attribute (e.g., older sklearn versions).
fix
Upgrade scikit-learn to 0.24+ or use the forestci compatible version. Check estimator type.
affects: 0.7
Upgrade
Version history
0.7latest on PyPI · released Jul 9, 2024
Audit
Dependencies
scikit-learnrequiredforestci works with scikit-learn's forest estimators; requires sklearn >= 0.21
numpyrequiredused for array operations
scipyrequiredused for statistical functions
Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
forestci — pip install forestci · libregistry