{"id":23761,"library":"forestci","title":"forestci: confidence intervals for scikit-learn forest algorithms","description":"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.","status":"active","version":"0.7","language":"python","source_language":"en","source_url":"http://github.com/scikit-learn-contrib/forest-confidence-interval","tags":["confidence intervals","random forest","scikit-learn","infinitesimal jackknife","machine learning"],"install":[{"cmd":"pip install forestci","lang":"bash","label":"pip install forestci"}],"dependencies":[{"reason":"forestci works with scikit-learn's forest estimators; requires sklearn >= 0.21","package":"scikit-learn","optional":false},{"reason":"used for array operations","package":"numpy","optional":false},{"reason":"used for statistical functions","package":"scipy","optional":false}],"imports":[{"note":"main function for computing confidence intervals","symbol":"calc_inference","correct":"from forestci import calc_inference"},{"note":"computes bias-corrected error variance","symbol":"random_forest_error","correct":"from forestci import random_forest_error"},{"note":"forestci is a module, not a function; do not import as a submodule","wrong":"from forestci import forestci","symbol":"forestci","correct":"import forestci"}],"quickstart":{"code":"from sklearn.ensemble import RandomForestRegressor\nfrom sklearn.datasets import make_regression\nfrom forestci import random_forest_error\nimport numpy as np\n\nX, y = make_regression(n_samples=100, n_features=4, noise=0.1, random_state=42)\nrf = RandomForestRegressor(n_estimators=100, random_state=42)\nrf.fit(X, y)\npred = rf.predict(X)\nerror_var = random_forest_error(rf, X, X)\n# 95% confidence interval\nci = 1.96 * np.sqrt(error_var)\nprint(ci[:5])","lang":"python","description":"Compute confidence intervals for RandomForestRegressor predictions using the infinitesimal jackknife."},"warnings":[{"fix":"Use X_train as the 'inbag' argument or pass the training data explicitly.","message":"random_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.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace calc_inference with random_forest_error(\n    rf, X_test, X_train\n) + manual CI computation.","message":"calc_inference (formerly calc_corr) has been deprecated. Use random_forest_error for variance estimation and then compute confidence intervals manually.","severity":"gotcha","affected_versions":">=0.6"},{"fix":"Upgrade scikit-learn to 0.24+ or use the forestci compatible version. Check estimator type.","message":"In 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).","severity":"gotcha","affected_versions":"0.7"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Upgrade scikit-learn to >= 0.24 or use a workaround: pass inbag matrix manually via inbag parameter or use a patch.","cause":"Scikit-learn version < 0.24 does not expose estimators_samples_ attribute used by forestci for inbag calculation.","error":"AttributeError: 'RandomForestRegressor' object has no attribute 'estimators_samples_'"},{"fix":"pip install forestci","cause":"forestci is not installed, or installed in a different environment.","error":"ModuleNotFoundError: No module named 'forestci'"},{"fix":"Provide both X_test (data for which to compute errors) and X_train (training data).","cause":"Call signature is random_forest_error(forest, X_test, X_train) with both X_test and X_train required.","error":"TypeError: random_forest_error() missing 1 required positional argument: 'X_test'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}