Skip to main content

forest-stream

Honest causal and instrumental forests, quantile forests, regression forests, random forests and decision trees for data with millions of rows, with fixed effects removed by hdfe-stream. The features are binned into a file on disk and the trees are grown in memory-budgeted batches from passes over that file, so a fit needs a few gigabytes however many rows there are.

import forest_stream as fs

# how the effect of a treatment varies: outcome ~ treatment | the features it may vary with
fit = fs.causal_forest("earnings ~ enrolled | age + education + prior_earnings", "jobs.parquet")
fit.average_treatment_effect().summary()   # the average effect, with a standard error
fit.oob_predictions()                      # each row's effect and its variance
fit.calibration_test()                     # is the heterogeneity real?
fit.predict("new_people.parquet")          # effects for other rows, in batches

# the same when an instrument moves the treatment rather than assigning it
fs.instrumental_forest("earnings ~ enrolled | age + education", "jobs.parquet", instrument="offered")

# worker and firm fixed effects, removed by backfitting
fs.causal_forest("log_wage ~ trained | tenure + hours | worker_id + firm_id", "panel.parquet")

# prediction: a numeric outcome (with a fixed effect) or class labels, and one readable tree
fs.regression_forest("price ~ area + rooms + age | region", "sales.parquet")
fs.random_forest("default ~ income + debt + age", "loans.parquet").oob_score()
fs.decision_tree("default ~ income + debt + age", "loans.parquet", max_depth=4).tree()

The data are a Parquet path, a glob, or a Polars frame. Rows can be weighted, clustered, and predicted in batches to a file; the fixed effects can be removed by backfitting (the default), by demeaning the outcome, or by adding group means as features.

What it does

Function Estimates
causal_forest How the effect of a treatment differs across rows, with a variance for each estimate and the average effect's standard error; calibration test and best linear projection
instrumental_forest The local effects of a treatment that an instrument moves, with the same variances and average
quantile_forest Conditional quantiles of an outcome, at any levels
regression_forest The conditional mean, with variances for the predictions
random_forest The conditional mean, or class probabilities
decision_tree One tree, as a table of nodes

The methods are those of Breiman (2001), Wager and Athey (2018) and Athey, Tibshirani and Wager (2019); the documentation compares the options with those of grf, ranger, rpart and EconML, and says where the results differ.

When to use it, and when not

Use it when the data are too large for a forest in memory, when there are fixed effects too numerous to enter as dummies, or when you need a causal forest's inference on data that grf cannot hold. Use grf, ranger or scikit-learn when the data are small (under about 100,000 rows), when you need multi-arm, survival or quantile forests, or when you want boosting.

Install

pip install -e .

Python 3.10 or later. It depends on hdfe-stream, stream-limits, Polars, NumPy, numba, SciPy and pyarrow. See the documentation.

A sibling of hdfe-stream, diff-stream, match-stream, penalized-stream and rd-stream.

License

MIT.

Metadata

Release files for forest-stream 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for forest-stream 0.1.0
File Size Uploaded Provenance Actions
forest_stream-0.1.0.tar.gz 95.9 kB With provenance Details for forest_stream-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for forest-stream 0.1.0
File Interpreter ABI Platform Actions
forest_stream-0.1.0-py3-none-any.whl Python 3 none any Details for forest_stream-0.1.0-py3-none-any.whl

Total release size: 170.7 kB

Release files / forest_stream-0.1.0.tar.gz

Download URL forest_stream-0.1.0.tar.gz
Size 95.9 kB
Tags Source
SHA-256 checksum
How to use checksums
47fb3f67aafaf2a1c71edc837b1fe105eece34c9dbbc99e291d1af069544e78b
BLAKE2b-256 checksum
How to use checksums
b88a050885c2f5dec69c58cd38478eb6f4e44aa45da21db4dce9e1c544c35576
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / forest_stream-0.1.0-py3-none-any.whl

Download URL forest_stream-0.1.0-py3-none-any.whl
Size 74.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cc266c25c77c664fb2f3889faa0ba33c5e41f473801440385db0eac94a15e0a
BLAKE2b-256 checksum
How to use checksums
d195722a2554186b4e3a6a10a699b0045f0bce04be6117e1e4935365fdce2779
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for forest-stream 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for forest_stream-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page