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.
Release files for skgrf 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| skgrf-0.3.0.tar.gz | 1.8 MB | Details |
Built distributions (wheels)
Total release size: 25.1 MB
Release files / skgrf-0.3.0.tar.gz
| Download URL | skgrf-0.3.0.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be3537a74683022097fdc7020697f5be1b26c9905b4047c5e1ee4e37f76a5894
|
|
BLAKE2b-256 checksum How to use checksums |
3de6e4df6cf0eaa5e5659d9c4024dec84d769b375c2c264b2870856d1d72ddbf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.2 Darwin/20.1.0
|
Release files / skgrf-0.3.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
| Download URL | skgrf-0.3.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.9 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
0fbcfc09d0a861f456638d40d376460cc69279b50799157c8a5b2ee1364abceb
|
|
BLAKE2b-256 checksum How to use checksums |
a4e01a00de0a84ae5255ba93bd4be14529e6b33d56b25daa540210deb2d384e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / skgrf-0.3.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl
| Download URL | skgrf-0.3.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.9 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
fcf7e5bf32af910408ad45571b01e40e022e663d3e0851cdf73375adea0e4718
|
|
BLAKE2b-256 checksum How to use checksums |
de9496609d7c9b5a17d16501521161db8a7fc95a83269cae50cba58ce2fcbb86
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / skgrf-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl
| Download URL | skgrf-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.9 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
212cb4f1184f6e7ddeb4d3c3d31c717547d485f175355ec3c38948c8047cda1a
|
|
BLAKE2b-256 checksum How to use checksums |
7411f46646b516a95af2dcb965496ef06cb0ff164350f5f2501db5cedf763788
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4
|
Release files / skgrf-0.3.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
| Download URL | skgrf-0.3.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
aeb4acfe533ad72361e18cb448d367d052115400192ab9582533e3162d54f805
|
|
BLAKE2b-256 checksum How to use checksums |
eaf1dad1af55c96c4252d7ad1135ae23e7f664cdb2c94e83d4775f3c59db82fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / skgrf-0.3.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
| Download URL | skgrf-0.3.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl |
|---|---|
| Size | 2.5 MB |
| Tags | CPython 3.8 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
9d0e0a51c8c45085aafded88441966c2efa850ef7e948c071702cf34d9da8bf6
|
|
BLAKE2b-256 checksum How to use checksums |
02853093712610744f6d18653bb1ec3bde657046a5c8e34d57aafa785aa6e432
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / skgrf-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl
| Download URL | skgrf-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.8 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
183420e85d3d47450a76c2d8047c711d44d07c2d2236d601a318c466fe96090b
|
|
BLAKE2b-256 checksum How to use checksums |
7dfe3893aafef7f917565ac54a832e3d661f90edf8af950343347cd4365a403e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.9
|
Release files / skgrf-0.3.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
| Download URL | skgrf-0.3.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
1592122e1499d114217e1b043bb27bffe7a2d3a68628a639a406501c1f52b06b
|
|
BLAKE2b-256 checksum How to use checksums |
7a900e3fd709b1ed5c3f75463a167e2ebcb5000ed9a4258f49abae44d13ada1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / skgrf-0.3.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl
| Download URL | skgrf-0.3.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
b8180b2fdf61881fd37b0ca6cf7682556ec351d15bbdad49a88517f1697f2104
|
|
BLAKE2b-256 checksum How to use checksums |
46e333be96ecdadc647bdc92d8c2ad138b6940946747333ef13becda551ac8f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
|
Release files / skgrf-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl
| Download URL | skgrf-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl |
|---|---|
| Size | 2.6 MB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
de3f3bfbe562dbd3975a1bc4e3aa34e63a51c4dd4c84b23d34be51cad56d3479
|
|
BLAKE2b-256 checksum How to use checksums |
b885c6b510ec850b51deec596fdb1175c87c32eba43ef9a4f2cc252049937cce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.9
|