Random forest estimator
Project description
This is an experimental fork of Rforestry, for the package repo, see (https://github.com/forestry-labs/Rforestry)
Rforestry: Random Forests, Linear Trees, and Gradient Boosting for Inference and Interpretability
Sören Künzel, Theo Saarinen, Simon Walter, Sam Antonyan, Edward Liu, Allen Tang, Jasjeet Sekhon
Introduction
Rforestry is a fast implementation of Honest Random Forests, Gradient Boosting, and Linear Random Forests, with an emphasis on inference and interpretability.
How to install - R Package
- The GFortran compiler has to be up to date. GFortran Binaries can be found here.
- The devtools package has to be installed. You can install it using,
install.packages("devtools")
. - 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 and macOS users download and install Xcode. - The latest development version can then be installed using
devtools::install_github("forestry-labs/Rforestry")
. For Windows users, you'll need to skip 64-bit compilationdevtools::install_github("forestry-labs/Rforestry", INSTALL_opts = c('--no-multiarch'))
due to an outstanding gcc issue.
How to install - Python Package
The python package must be compiled before it can be used. Note that to compile and link the C++ version of forestry, one must be using either OSX or Linux and must have a C++ compiler installed. For example, one can run:
mkdir build
cd build
cmake .
make
Python Package Usage
Then the python code can be called:
import numpy as np
import pandas as pd
from random import randrange
from Rforestry import RandomForest
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
data = load_iris()
df = pd.DataFrame(data['data'], columns=data['feature_names'])
df['target'] = data['target']
X = df.loc[:, df.columns != 'sepal length (cm)']
y = df['sepal length (cm)']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
fr = RandomForest(ntree = 500)
print("Fitting the forest")
fr.fit(X_train, y_train)
print("Predicting with the forest")
forest_preds = fr.predict(X_test)
Plotting the forest
For visualizing the trees, make sure to install the dtreeviz python library.
from dtreeviz.trees import *
from forestry_shadow import ShadowForestryTree
shadow_forestry = ShadowForestryTree(fr, X, y, X.columns.values, 'sepal length (cm)', tree_id=0)
viz = dtreeviz(shadow_forestry,
scale=3.0,
target_name='sepal length (cm)',
feature_names=X.columns.values)
viz.view()
R Package Usage
set.seed(292315) test_idx <- sample(nrow(iris), 3) x_train <- iris[-test_idx, -1] y_train <- iris[-test_idx, 1] x_test <- iris[test_idx, -1]
rf <- forestry(x = x_train, y = y_train, nthread = 2)
predict(rf, x_test)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file random-forestry-0.10.0b1.tar.gz
.
File metadata
- Download URL: random-forestry-0.10.0b1.tar.gz
- Upload date:
- Size: 270.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58e0ccc4a64ae73f9900fcf94078a681a4cdd3182a654a0d7987cb395da037de |
|
MD5 | 2c66f9a87de2c3ce8c45236d1ee08d5f |
|
BLAKE2b-256 | 1671a1118265954fdf66cf9f5ff6418ed55f2e3ededcbfaf0e99fc209e6bfaac |
File details
Details for the file random_forestry-0.10.0b1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 22.0 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3de68abca03f6b7fa33b23c2a2a3085a1d0e6b3e3aec872172a00e0a2160f8dd |
|
MD5 | f6a40482bb9abbd6c3333489f064fae6 |
|
BLAKE2b-256 | ddcebc44aa49a2caa1c4f5f2d5f6281288fc53846ab9efca7a7c367fcf840868 |
File details
Details for the file random_forestry-0.10.0b1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 212.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4184cf2826a4ec99d83b7d9b7185079ad5b0f9a63cc26e15256e02da1be0fb38 |
|
MD5 | 282179adcd541867319f7fed8125ec28 |
|
BLAKE2b-256 | f7679276c88bd2bb7316fd42c2461064a865724dc4a1aadcea57dc77db746b5c |
File details
Details for the file random_forestry-0.10.0b1-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 14.8 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21481aa76d0de0b61be536c24c0a4aece35189af0db86b003edef3ced5b28b3a |
|
MD5 | ed4d453d969f00efb8135d636bacc712 |
|
BLAKE2b-256 | 28d8d27535e4e57889e2deae1d820713202228f2940cb8586a27ad1ad9739136 |
File details
Details for the file random_forestry-0.10.0b1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 22.0 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3bd08a2f6a7b82bb6a837b5d676d96e50e7a8e96bcba5e92bb178337b199a07 |
|
MD5 | 465cb73d85b40ba62bcfa3003311c141 |
|
BLAKE2b-256 | 69dcc7a8a73340b9eb7409ce9c5f13e24fea91860e93a12d298f71c986a9fa0a |
File details
Details for the file random_forestry-0.10.0b1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 212.2 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba59a0089143e47b15976e8f9fc82bb7b881713aaec0d454763285913d9c2f93 |
|
MD5 | 24f8c74961862a6b4e4f403c885dd647 |
|
BLAKE2b-256 | 07487ca75207e3e2e65dbca597033377b351188f119e046dd2618d8e1daa1148 |
File details
Details for the file random_forestry-0.10.0b1-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 14.8 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05e3772a32b2d12351ec16f9df0ab71d4b5d7a82956cff8a2a738c2ca315be7a |
|
MD5 | 514271c88eaa97f71e616b6c895ad4e8 |
|
BLAKE2b-256 | 1780e732c93fcd611c03ccfad0f1b5fc3ee37ad1c32f3d76444a6be3f6e5344e |
File details
Details for the file random_forestry-0.10.0b1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 22.0 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 891ba649f28daade04853a4de1ac31e08227fc1ef9485165d8ceed2bb5ba1a5f |
|
MD5 | 352d47cc3531ef1d7b68eeedeb2c663a |
|
BLAKE2b-256 | d49bcc97f3fb4cf2893853f49843752df2ce0236568ea34b2d52c0e231627d4e |
File details
Details for the file random_forestry-0.10.0b1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 212.4 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86941fd65a16c2a5d9b5975b8b18668af0e1cfafd666f9b3c1a874d562732242 |
|
MD5 | 73f550db65bfe260e31909803264b9d8 |
|
BLAKE2b-256 | db6727bf27467cef929d1f33884b2d896bc9e6fdc5e3d733f9f5a8b05cedb141 |
File details
Details for the file random_forestry-0.10.0b1-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 14.8 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cae1291bcacb1e58e9904d529d117336655b71cbcab4d2717e80a8becf07c370 |
|
MD5 | d11211d1649c25a42aa33be31e1f2a8a |
|
BLAKE2b-256 | e7c444828fd9beb822a2cf799dd1789cba3f85f899f0c9f93c178146ade232b3 |
File details
Details for the file random_forestry-0.10.0b1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 22.0 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a96f30622468f56c9600719bdde76adf6ecb8168b7f56eace03a4acffde8fc17 |
|
MD5 | 1bedf90b0e9c844492334b0fa22a30d5 |
|
BLAKE2b-256 | 75e63161596247eafdf9f46cbf5f256d145150e0c31f505a13dd9c7c6ce5a766 |
File details
Details for the file random_forestry-0.10.0b1-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 212.4 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f1f4c9634e73329be493b9ae74fcbd16493e6fc2526111eed5f55c965e4a501 |
|
MD5 | e719bfc8306f5877e8c328ec66a3ed24 |
|
BLAKE2b-256 | 87e743e897acd21c9e1bf5cc19a4080d323625b5f41007c97602d10ec7497a47 |
File details
Details for the file random_forestry-0.10.0b1-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: random_forestry-0.10.0b1-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 14.8 MB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f9bfedefd376c8ba68fbace820194be57aa7d5656d0c7b0c5e81332aa79f27 |
|
MD5 | 961e4574f968fb4cc1cbb3c83003bb35 |
|
BLAKE2b-256 | 77d578123517cd83f51a9828313b54ceecc9da7bde97d1fe663297228ac7b6e3 |