{"id":13398634,"url":"https://github.com/grf-labs/grf","last_synced_at":"2025-10-21T20:05:20.653Z","repository":{"id":37359610,"uuid":"65554548","full_name":"grf-labs/grf","owner":"grf-labs","description":"Generalized Random Forests ","archived":false,"fork":false,"pushed_at":"2025-10-09T14:19:46.000Z","size":65574,"stargazers_count":1050,"open_issues_count":64,"forks_count":264,"subscribers_count":46,"default_branch":"master","last_synced_at":"2025-10-18T04:46:46.294Z","etag":null,"topics":["causal-forest","causal-inference","econometrics","machine-learning","random-forest","statistics"],"latest_commit_sha":null,"homepage":"https://grf-labs.github.io/grf/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grf-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE.md","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-08-12T13:17:37.000Z","updated_at":"2025-10-18T02:45:14.000Z","dependencies_parsed_at":"2023-02-14T03:46:01.888Z","dependency_job_id":"12349ce5-c6a2-473c-817f-baa140cfab56","html_url":"https://github.com/grf-labs/grf","commit_stats":{"total_commits":1771,"total_committers":32,"mean_commits":55.34375,"dds":0.6990400903444381,"last_synced_commit":"e253e21fefe43002898f5785838e9617baaa4aaa"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/grf-labs/grf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grf-labs%2Fgrf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grf-labs%2Fgrf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grf-labs%2Fgrf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grf-labs%2Fgrf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grf-labs","download_url":"https://codeload.github.com/grf-labs/grf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grf-labs%2Fgrf/sbom","scorecard":{"id":445424,"data":{"date":"2025-08-11","repo":{"name":"github.com/grf-labs/grf","commit":"8b8b6408fcafd66f25639ce437274acefd1b48fe"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.7,"checks":[{"name":"Code-Review","score":1,"reason":"Found 5/30 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":10,"reason":"GitHub workflow tokens follow principle of least privilege","details":["Info: topLevel 'contents' permission set to 'read': .github/workflows/pages.yml:10","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":7,"reason":"3 commit(s) and 6 issue activity found in the last 90 days -- score normalized to 7","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: COPYING:0","Info: FSF or OSI recognized license: GNU General Public License v3.0: COPYING:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/grf-labs/grf/pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:59: update your workflow using https://app.stepsecurity.io/secureworkflow/grf-labs/grf/pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/grf-labs/grf/pages.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/pages.yml:66: update your workflow using https://app.stepsecurity.io/secureworkflow/grf-labs/grf/pages.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T06:37:05.360Z","repository_id":37359610,"created_at":"2025-08-19T06:37:05.360Z","updated_at":"2025-08-19T06:37:05.360Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280325300,"owners_count":26311419,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["causal-forest","causal-inference","econometrics","machine-learning","random-forest","statistics"],"created_at":"2024-07-30T19:00:29.679Z","updated_at":"2025-10-21T20:05:20.646Z","avatar_url":"https://github.com/grf-labs.png","language":"C++","readme":"# generalized random forests \u003ca href='https://grf-labs.github.io/grf/'\u003e\u003cimg src='https://raw.githubusercontent.com/grf-labs/grf/master/images/logo/grf_logo_wbg_cropped.png' align=\"right\" height=\"120\" /\u003e\u003c/a\u003e\n\n[![CRANstatus](https://www.r-pkg.org/badges/version/grf)](https://cran.r-project.org/package=grf)\n[![](https://cranlogs.r-pkg.org/badges/grand-total/grf)](https://cran.r-project.org/package=grf)\n[![Build Status](https://dev.azure.com/grf-labs/grf/_apis/build/status/grf-labs.grf?branchName=master)](https://dev.azure.com/grf-labs/grf/_build/latest?definitionId=2\u0026branchName=master)\n\nA package for forest-based statistical estimation and inference. GRF provides non-parametric methods for heterogeneous treatment effects estimation (optionally using right-censored outcomes, multiple treatment arms or outcomes, or instrumental variables), as well as least-squares regression, quantile regression, and survival regression, all with support for missing covariates.\n\nIn addition, GRF supports 'honest' estimation (where one subset of the data is used for choosing splits, and another for populating the leaves of the tree), and confidence intervals for least-squares regression and treatment effect estimation.\n\nSome helpful links for getting started:\n\n- The [R package documentation](https://grf-labs.github.io/grf/) contains usage examples and method reference.\n- The [GRF reference](https://grf-labs.github.io/grf/REFERENCE.html) gives a detailed description of the GRF algorithm and includes troubleshooting suggestions.\n- For community questions and answers around usage, see [Github issues labelled 'question'](https://github.com/grf-labs/grf/issues?q=label%3Aquestion).\n\nThe repository first started as a fork of the [ranger](https://github.com/imbs-hl/ranger) repository -- we owe a great deal of thanks to the ranger authors for their useful and free package.\n\n### Installation\n\nThe latest release of the package can be installed through CRAN:\n\n```R\ninstall.packages(\"grf\")\n```\n\n`conda` users can install from the [conda-forge](https://anaconda.org/conda-forge/r-grf) channel:\n\n```\nconda install -c conda-forge r-grf\n```\n\nThe current development version can be installed from source using devtools.\n\n```R\ndevtools::install_github(\"grf-labs/grf\", subdir = \"r-package/grf\")\n```\n\nNote that to install from source, a compiler that implements C++11 or later is required. If installing on Windows, the RTools toolchain is also required.\n\n### Usage Examples\n\nThe following script demonstrates how to use GRF for heterogeneous treatment effect estimation. For examples\nof how to use other types of forests, please consult the R [documentation](https://grf-labs.github.io/grf/reference/index.html) on the relevant methods.\n\n```R\nlibrary(grf)\n\n# Generate data.\nn \u003c- 2000\np \u003c- 10\nX \u003c- matrix(rnorm(n * p), n, p)\nX.test \u003c- matrix(0, 101, p)\nX.test[, 1] \u003c- seq(-2, 2, length.out = 101)\n\n# Train a causal forest.\nW \u003c- rbinom(n, 1, 0.4 + 0.2 * (X[, 1] \u003e 0))\nY \u003c- pmax(X[, 1], 0) * W + X[, 2] + pmin(X[, 3], 0) + rnorm(n)\ntau.forest \u003c- causal_forest(X, Y, W)\n\n# Estimate treatment effects for the training data using out-of-bag prediction.\ntau.hat.oob \u003c- predict(tau.forest)\nhist(tau.hat.oob$predictions)\n\n# Estimate treatment effects for the test sample.\ntau.hat \u003c- predict(tau.forest, X.test)\nplot(X.test[, 1], tau.hat$predictions, ylim = range(tau.hat$predictions, 0, 2), xlab = \"x\", ylab = \"tau\", type = \"l\")\nlines(X.test[, 1], pmax(0, X.test[, 1]), col = 2, lty = 2)\n\n# Estimate the conditional average treatment effect on the full sample (CATE).\naverage_treatment_effect(tau.forest, target.sample = \"all\")\n\n# Estimate the conditional average treatment effect on the treated sample (CATT).\naverage_treatment_effect(tau.forest, target.sample = \"treated\")\n\n# Add confidence intervals for heterogeneous treatment effects; growing more trees is now recommended.\ntau.forest \u003c- causal_forest(X, Y, W, num.trees = 4000)\ntau.hat \u003c- predict(tau.forest, X.test, estimate.variance = TRUE)\nsigma.hat \u003c- sqrt(tau.hat$variance.estimates)\nplot(X.test[, 1], tau.hat$predictions, ylim = range(tau.hat$predictions + 1.96 * sigma.hat, tau.hat$predictions - 1.96 * sigma.hat, 0, 2), xlab = \"x\", ylab = \"tau\", type = \"l\")\nlines(X.test[, 1], tau.hat$predictions + 1.96 * sigma.hat, col = 1, lty = 2)\nlines(X.test[, 1], tau.hat$predictions - 1.96 * sigma.hat, col = 1, lty = 2)\nlines(X.test[, 1], pmax(0, X.test[, 1]), col = 2, lty = 1)\n\n# In some examples, pre-fitting models for Y and W separately may\n# be helpful (e.g., if different models use different covariates).\n# In some applications, one may even want to get Y.hat and W.hat\n# using a completely different method (e.g., boosting).\n\n# Generate new data.\nn \u003c- 4000\np \u003c- 20\nX \u003c- matrix(rnorm(n * p), n, p)\nTAU \u003c- 1 / (1 + exp(-X[, 3]))\nW \u003c- rbinom(n, 1, 1 / (1 + exp(-X[, 1] - X[, 2])))\nY \u003c- pmax(X[, 2] + X[, 3], 0) + rowMeans(X[, 4:6]) / 2 + W * TAU + rnorm(n)\n\nforest.W \u003c- regression_forest(X, W, tune.parameters = \"all\")\nW.hat \u003c- predict(forest.W)$predictions\n\nforest.Y \u003c- regression_forest(X, Y, tune.parameters = \"all\")\nY.hat \u003c- predict(forest.Y)$predictions\n\nforest.Y.varimp \u003c- variable_importance(forest.Y)\n\n# Note: Forests may have a hard time when trained on very few variables\n# (e.g., ncol(X) = 1, 2, or 3). We recommend not being too aggressive\n# in selection.\nselected.vars \u003c- which(forest.Y.varimp / mean(forest.Y.varimp) \u003e 0.2)\n\ntau.forest \u003c- causal_forest(X[, selected.vars], Y, W,\n                            W.hat = W.hat, Y.hat = Y.hat,\n                            tune.parameters = \"all\")\n\n# See if a causal forest succeeded in capturing heterogeneity by plotting\n# the TOC and calculating a 95% CI for the AUTOC.\ntrain \u003c- sample(1:n, n / 2)\ntrain.forest \u003c- causal_forest(X[train, ], Y[train], W[train])\neval.forest \u003c- causal_forest(X[-train, ], Y[-train], W[-train])\nrate \u003c- rank_average_treatment_effect(eval.forest,\n                                      predict(train.forest, X[-train, ])$predictions)\nplot(rate)\npaste(\"AUTOC:\", round(rate$estimate, 2), \"+/\", round(1.96 * rate$std.err, 2))\n```\n\n### Developing\n\nIn addition to providing out-of-the-box forests for quantile regression and causal effect estimation, GRF provides a framework for creating forests tailored to new statistical tasks. If you'd like to develop using GRF, please consult the [algorithm reference](https://grf-labs.github.io/grf/REFERENCE.html) and [development guide](https://grf-labs.github.io/grf/DEVELOPING.html).\n\n### Funding\n\nDevelopment of GRF is supported by the National Institutes of Health, the National Science Foundation, the Sloan Foundation, the Office of Naval Research (Grant N00014-17-1-2131) and Schmidt Futures.\n\n### References\n\nSusan Athey and Stefan Wager.\n\u003cb\u003eEstimating Treatment Effects with Causal Forests: An Application.\u003c/b\u003e\n\u003ci\u003eObservational Studies\u003c/i\u003e, 5, 2019.\n[\u003ca href=\"https://doi.org/10.1353/obs.2019.0001\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/1902.07409\"\u003earxiv\u003c/a\u003e]\n\nSusan Athey, Julie Tibshirani and Stefan Wager.\n\u003cb\u003eGeneralized Random Forests.\u003c/b\u003e \u003ci\u003eAnnals of Statistics\u003c/i\u003e, 47(2), 2019.\n[\u003ca href=\"https://projecteuclid.org/euclid.aos/1547197251\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/1610.01271\"\u003earxiv\u003c/a\u003e]\n\nYifan Cui, Michael R. Kosorok, Erik Sverdrup, Stefan Wager, and Ruoqing Zhu.\n\u003cb\u003eEstimating Heterogeneous Treatment Effects with Right-Censored Data via Causal Survival Forests.\u003c/b\u003e\n\u003ci\u003eJournal of the Royal Statistical Society: Series B\u003c/i\u003e, 85(2), 2023.\n[\u003ca href=\"https://doi.org/10.1093/jrsssb/qkac001\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/2001.09887\"\u003earxiv\u003c/a\u003e]\n\nRina Friedberg, Julie Tibshirani, Susan Athey, and Stefan Wager.\n\u003cb\u003eLocal Linear Forests.\u003c/b\u003e \u003ci\u003eJournal of Computational and Graphical Statistics\u003c/i\u003e, 30(2), 2020.\n[\u003ca href=\"https://www.tandfonline.com/doi/abs/10.1080/10618600.2020.1831930\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/1807.11408\"\u003earxiv\u003c/a\u003e]\n\nImke Mayer, Erik Sverdrup, Tobias Gauss, Jean-Denis Moyer, Stefan Wager and Julie Josse.\n\u003cb\u003eDoubly Robust Treatment Effect Estimation with Missing Attributes.\u003c/b\u003e\n\u003ci\u003eAnnals of Applied Statistics\u003c/i\u003e, 14(3), 2020.\n[\u003ca href=\"https://projecteuclid.org/euclid.aoas/1600454872\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/pdf/1910.10624.pdf\"\u003earxiv\u003c/a\u003e]\n\nErik Sverdrup, Maria Petukhova, and Stefan Wager.\n\u003cb\u003eEstimating Treatment Effect Heterogeneity in Psychiatry: A Review and Tutorial with Causal Forests.\u003c/b\u003e\n\u003ci\u003eInternational Journal of Methods in Psychiatric Research\u003c/i\u003e, 34(2), 2025.\n[\u003ca href=\"https://doi.org/10.1002/mpr.70015\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/2409.01578\"\u003earxiv\u003c/a\u003e]\n\nErik Sverdrup, James Yang, and Michael LeBlanc.\n\u003cb\u003eEfficient Log-Rank Updates for Random Survival Forests.\u003c/b\u003e 2025.\n[\u003ca href=\"https://arxiv.org/abs/2510.03665\"\u003earxiv\u003c/a\u003e]\n\nStefan Wager.\n\u003cb\u003eCausal Inference: A Statistical Learning Approach.\u003c/b\u003e 2024.\n[\u003ca href=\"https://web.stanford.edu/~swager/causal_inf_book.pdf\"\u003epdf\u003c/a\u003e]\n\nStefan Wager and Susan Athey.\n\u003cb\u003eEstimation and Inference of Heterogeneous Treatment Effects using Random Forests.\u003c/b\u003e\n\u003ci\u003eJournal of the American Statistical Association\u003c/i\u003e, 113(523), 2018.\n[\u003ca href=\"https://www.tandfonline.com/eprint/v7p66PsDhHCYiPafTJwC/full\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/1510.04342\"\u003earxiv\u003c/a\u003e]\n\nSteve Yadlowsky, Scott Fleming, Nigam Shah, Emma Brunskill, and Stefan Wager.\n\u003cb\u003eEvaluating Treatment Prioritization Rules via Rank-Weighted Average Treatment Effects.\u003c/b\u003e\n\u003ci\u003eJournal of the American Statistical Association\u003c/i\u003e, 120(549), 2025.\n[\u003ca href=\"https://doi.org/10.1080/01621459.2024.2393466\"\u003epaper\u003c/a\u003e,\n\u003ca href=\"https://arxiv.org/abs/2111.07966\"\u003earxiv\u003c/a\u003e]\n","funding_links":[],"categories":["Causal Inference and Econometrics","C++","Causal Inference","Tools","Uncategorized"],"sub_categories":["Core Libraries","Others","Causal Inference","Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrf-labs%2Fgrf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrf-labs%2Fgrf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrf-labs%2Fgrf/lists"}