python bindings for C++ generalized random forests (grf)
Project description
skgrf provides scikit-learn compatible Python bindings to the C++ random forest implementation, grf, using Cython.
The latest release of skgrf uses version 2.0.0 of grf.
skgrf is still in development. Please create issues for any discrepancies or errors. PRs welcome.
Documentation
Installation
skgrf is available on pypi and can be installed via pip:
pip install skgrf
Estimators
GRFForestCausalRegressor
GRFForestInstrumentalRegressor
GRFForestLocalLinearRegressor
GRFForestQuantileRegressor
GRFForestRegressor
GRFBoostedForestRegressor
GRFForestSurvival
Usage
GRFForestRegressor
The GRFForestRegressor predictor uses grf’s RegressionPredictionStrategy class.
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
from skgrf.ensemble import GRFForestRegressor
X, y = load_boston(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y)
forest = GRFForestRegressor()
forest.fit(X_train, y_train)
predictions = forest.predict(X_test)
print(predictions)
# [31.81349144 32.2734354 16.51560285 11.90284392 39.69744341 21.30367911
# 19.52732937 15.82126562 26.49528961 11.27220097 16.02447197 20.01224404
# ...
# 20.70674263 17.09041289 12.89671205 20.79787926 21.18317924 25.45553279
# 20.82455595]
GRFForestQuantileRegressor
The GRFForestQuantileRegressor predictor uses grf’s QuantilePredictionStrategy class.
from sklearn.datasets import load_boston
from sklearn.model_selection import train_test_split
from skgrf.ensemble import GRFForestQuantileRegressor
X, y = load_boston(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y)
forest = GRFForestQuantileRegressor(quantiles=[0.1, 0.9])
forest.fit(X_train, y_train)
predictions = forest.predict(X_test)
print(predictions)
# [[21.9 50. ]
# [ 8.5 24.5]
# ...
# [ 8.4 18.6]
# [ 8.1 20. ]]
License
skgrf is licensed under GPLv3.
Development
To develop locally, it is recommended to have asdf, make and a C++ compiler already installed. After cloning, run make setup. This will setup the grf submodule, install python and poetry from .tool-versions, install dependencies using poetry, copy the grf source code into skgrf, and then build and install skgrf in the local virtualenv.
To format code, run make fmt. This will run isort and black against the .py files.
To run tests and inspect coverage, run make test or make xtest for testing in parallel.
To rebuild in place after making changes, run make build.
To create python package artifacts, run make dist.
To build and view documentation, run make docs.
Project details
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
Hashes for skgrf-0.1.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4e2936f5d7d883f55ebb9d5f632cebd0e1b2a8d957d759ec7ae981cf61f7285 |
|
MD5 | cb18e38c158a049fc727a3deae9bdb9f |
|
BLAKE2b-256 | f61fdad23794d77396536a61e42f57b2153471fceada1162ca40b5ef2bd98f03 |
Hashes for skgrf-0.1.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df6efeffb3dfd67498374bd67a9d5d852e8c45827892570b27a1b80d8ab46bb5 |
|
MD5 | cf3319004b22d9b9cf1ac2d0f8ba5d0f |
|
BLAKE2b-256 | d65fe1b3b3e25ed8121c11be9a60641b5ae15b0afa364aff2633198f9d64d257 |
Hashes for skgrf-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d1407116badef26e93f729277892f9e9c4e05c652dba501bb465179234470ff |
|
MD5 | f53bc077efe9009b3315bbd2c199a415 |
|
BLAKE2b-256 | d11caf809f0718b4e507dacf92ced3700eae1648714f91279f3b92db227972c7 |
Hashes for skgrf-0.1.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b44db34eefe93b1293354eb75ae5e373db265ce04c244167d9bce3ba6269faba |
|
MD5 | 76943e675924fd053cfc51282d16e83b |
|
BLAKE2b-256 | b52fea7c8d392a50fb431bf6485cd6f87aa52df570f9771352e4a5c9ecc3d9e4 |
Hashes for skgrf-0.1.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24ac89787082fb88db0b7da566356a249592ecb2f254ca73feb49bbbeb56756e |
|
MD5 | e6a7e045a1640c1bf665af2456286df3 |
|
BLAKE2b-256 | 527b5f6283426e1ad2da59fc4ddc3255da2f5a04dfc5948b6d91d4460d4b61bb |
Hashes for skgrf-0.1.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a19a40fa6693de8b9b42329858124b1bec7e8117d673b1f09f1d88163a61258a |
|
MD5 | e068149eb7f77e0c8cace6bdc37f39a3 |
|
BLAKE2b-256 | b92212406eb62aa8063c24b0f0b41dfd38225d6df143e5172189c3276bb5c3ca |
Hashes for skgrf-0.1.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cae1023a8ed3c9614f1cdad4862448fca722dd9990fad646cc5e27a9ebbbf229 |
|
MD5 | ca6a44ac32759e8b5ac2c2a04460959b |
|
BLAKE2b-256 | 813c647fd31896058e015a5b46a97ca6b1ea0f548b8ef3539f396fcbe0fe28d7 |
Hashes for skgrf-0.1.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48577a2f1889b81dcbec3cbf9a5f6a8be052692cf4a279760ce9ea6ab8a0d655 |
|
MD5 | ab2e6c0f8b22d3c714117b5c76f45a11 |
|
BLAKE2b-256 | ae3e647ca6b516ebc00d3a06fdfef74155e72c8fae9e2dbd9f5b9e908ee39fa8 |
Hashes for skgrf-0.1.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4700fa8ae5d219cb7d625e21019b52a103c37a9d67dda22ce5632c17bce64dff |
|
MD5 | f9bb92c35acf09e1f128511fa40c1b87 |
|
BLAKE2b-256 | a6cb15bae67990f3bb4cbff404a1f07625ddc604a3aa11904fd79c7b9c98760f |
Hashes for skgrf-0.1.0-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe1e9f2d177529083e3bcaa5723d7c10ba8b9fce0c59bb07838d9535b2f9e3bf |
|
MD5 | 0dcf2567f56bfac35969f9f7c62c8550 |
|
BLAKE2b-256 | f63464c0f0088beb8790f09283422322cc145697725274a3625ec9e50eb11428 |
Hashes for skgrf-0.1.0-cp36-cp36m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 046285ec4cfbc1faac145ba6c301bb75ff3c0d0cae90f9ea9385af1346f62993 |
|
MD5 | 8fbc23adf7a670adac7a3497f66853c1 |
|
BLAKE2b-256 | 14f6622670b477ee6ba0a95d2de8a4aed7d89ff0dbf4ad595c38f04a1b09addd |
Hashes for skgrf-0.1.0-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94e6bc8a379da35d6b32877b2734d7f033145844aa169d729208e8c22612c763 |
|
MD5 | 7ed638c337f08e8510fde489f8511807 |
|
BLAKE2b-256 | d79fb80ff56cf26b1dfbb9e6dc7f8f781a95c73e3ac11c88c81acc5f0e4aafcf |