{"id":15051466,"url":"https://github.com/forestry-labs/rforestry","last_synced_at":"2025-04-10T02:41:16.508Z","repository":{"id":277816587,"uuid":"914961885","full_name":"forestry-labs/Rforestry","owner":"forestry-labs","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-12T00:03:57.000Z","size":121,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T04:11:25.579Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/forestry-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2025-01-10T17:05:01.000Z","updated_at":"2025-03-23T21:59:54.000Z","dependencies_parsed_at":"2025-02-24T17:27:48.101Z","dependency_job_id":null,"html_url":"https://github.com/forestry-labs/Rforestry","commit_stats":null,"previous_names":["forestry-labs/rforestry"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forestry-labs%2FRforestry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forestry-labs%2FRforestry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forestry-labs%2FRforestry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/forestry-labs%2FRforestry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/forestry-labs","download_url":"https://codeload.github.com/forestry-labs/Rforestry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144916,"owners_count":21055008,"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","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":["bagging","boosting","causal-inference","interpretability","machine-learning","monotonic-constraints","r","r-package","random-forest","random-forests","trees"],"created_at":"2024-09-24T21:35:44.579Z","updated_at":"2025-04-10T02:41:16.484Z","avatar_url":"https://github.com/forestry-labs.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![R-CMD-check](https://github.com/forestry-labs/Rforestry/actions/workflows/check-noncontainerized.yaml/badge.svg)](https://github.com/forestry-labs/Rforestry/actions/workflows/check-noncontainerized.yaml)\n\n## Rforestry: Random Forests, Linear Trees, and Gradient Boosting for Inference and Interpretability\n\nSören Künzel, Theo Saarinen, Simon Walter, Edward Liu, Allen Tang, Jasjeet Sekhon\n\n## Introduction\n\nRforestry is a fast implementation of Random Forests, Gradient Boosting,\nand Linear Random Forests, with an emphasis on inference and interpretability.\n\n## How to install\n1. The GFortran compiler has to be up to date. GFortran Binaries can be found [here](https://gcc.gnu.org/wiki/GFortranBinaries).\n2. The [devtools](https://github.com/hadley/devtools) package has to be installed. You can install it using,  `install.packages(\"devtools\")`.\n3. The package contains compiled code, and you must have a development environment to install the development version. You can use `devtools::has_devel()` to check whether you do. If no development environment exists, Windows users download and install [Rtools](https://cran.r-project.org/bin/windows/Rtools/) and macOS users download and install [Xcode](https://itunes.apple.com/us/app/xcode/id497799835).\n4. The latest development version can then be installed using\n`devtools::install_github(\"forestry-labs/Rforestry\")`. For Windows users, you'll need to skip 64-bit compilation `devtools::install_github(\"forestry-labs/Rforestry\", INSTALL_opts = c('--no-multiarch'))` due to an outstanding gcc issue.\n\n\n## Usage\n\n```R\nset.seed(292315)\nlibrary(Rforestry)\ntest_idx \u003c- sample(nrow(iris), 3)\nx_train \u003c- iris[-test_idx, -1]\ny_train \u003c- iris[-test_idx, 1]\nx_test \u003c- iris[test_idx, -1]\n\nrf \u003c- forestry(x = x_train, y = y_train)\nweights = predict(rf, x_test, aggregation = \"weightMatrix\")$weightMatrix\n\nweights %*% y_train\npredict(rf, x_test)\n```\n\n## Ridge Random Forest\n\nA fast implementation of random forests using ridge penalized splitting and ridge regression for predictions.\n\nExample:\n\n  ```R\nset.seed(49)\nlibrary(Rforestry)\n\nn \u003c- c(100)\na \u003c- rnorm(n)\nb \u003c- rnorm(n)\nc \u003c- rnorm(n)\ny \u003c- 4*a + 5.5*b - .78*c\nx \u003c- data.frame(a,b,c)\nforest \u003c- forestry(x, y, ridgeRF = TRUE)\npredict(forest, x)\n```\n\n## Monotonic Constraints\n\nA parameter controlling monotonic constraints for features in forestry.\n\n```R\nlibrary(Rforestry)\n\nx \u003c- rnorm(150)+5\ny \u003c- .15*x + .5*sin(3*x)\ndata_train \u003c- data.frame(x1 = x, x2 = rnorm(150)+5, y = y + rnorm(150, sd = .4))\n\nmonotone_rf \u003c- forestry(x = data_train %\u003e% select(-y),\n                        y = data_train$y,\n                        monotonicConstraints = c(-1,-1),\n                        nodesizeStrictSpl = 5,\n                        nthread = 1,\n                        ntree = 25)\npredict(monotone_rf, feature.new = data_train %\u003e% select(-y))\n\n```\n\n\n## OOB Predictions\n\nWe can return the predictions for the training dataset using only the trees in\nwhich each observation was out of bag. Note that when there are few trees, or a\nhigh proportion of the observations sampled, there may be some observations\nwhich are not out of bag for any trees.\nThe predictions for these are returned NaN.\n\n\n```R\nlibrary(Rforestry)\n\n# Train a forest\nrf \u003c- forestry(x = iris[,-1],\n               y = iris[,1],\n               ntree = 500)\n\n# Get the OOB predictions for the training set\noob_preds \u003c- getOOBpreds(rf)\n\n# This should be equal to the OOB error\nsum((oob_preds -  iris[,1])^2)\ngetOOB(rf)\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforestry-labs%2Frforestry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fforestry-labs%2Frforestry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fforestry-labs%2Frforestry/lists"}