Skip to main content

python bindings for C++ generalized random forests (grf)

Project description

actions wheels rtd pypi pyversions

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

skgrf-0.3.0.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

skgrf-0.3.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

skgrf-0.3.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl (2.6 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

skgrf-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

skgrf-0.3.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

skgrf-0.3.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl (2.5 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

skgrf-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.8 macOS 10.15+ x86-64

skgrf-0.3.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

skgrf-0.3.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl (2.6 MB view details)

Uploaded CPython 3.7m manylinux: glibc 2.5+ i686

skgrf-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.7m macOS 10.15+ x86-64

File details

Details for the file skgrf-0.3.0.tar.gz.

File metadata

  • Download URL: skgrf-0.3.0.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.2 Darwin/20.1.0

File hashes

Hashes for skgrf-0.3.0.tar.gz
Algorithm Hash digest
SHA256 be3537a74683022097fdc7020697f5be1b26c9905b4047c5e1ee4e37f76a5894
MD5 e65968f472cacf21d52e7a924ffb787c
BLAKE2b-256 3de6e4df6cf0eaa5e5659d9c4024dec84d769b375c2c264b2870856d1d72ddbf

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.9, manylinux: glibc 2.5+ x86-64
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0fbcfc09d0a861f456638d40d376460cc69279b50799157c8a5b2ee1364abceb
MD5 285478491f3bf9749d748c526233173e
BLAKE2b-256 a4e01a00de0a84ae5255ba93bd4be14529e6b33d56b25daa540210deb2d384e4

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.9, manylinux: glibc 2.5+ i686
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 fcf7e5bf32af910408ad45571b01e40e022e663d3e0851cdf73375adea0e4718
MD5 deb094731e406573cafd89c9481917f0
BLAKE2b-256 de9496609d7c9b5a17d16501521161db8a7fc95a83269cae50cba58ce2fcbb86

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 212cb4f1184f6e7ddeb4d3c3d31c717547d485f175355ec3c38948c8047cda1a
MD5 df69a0825fd40f90c16a0de0c899ce6b
BLAKE2b-256 7411f46646b516a95af2dcb965496ef06cb0ff164350f5f2501db5cedf763788

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.8, manylinux: glibc 2.5+ x86-64
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 aeb4acfe533ad72361e18cb448d367d052115400192ab9582533e3162d54f805
MD5 b4ec8783f3c5a263c55129483984e9ff
BLAKE2b-256 eaf1dad1af55c96c4252d7ad1135ae23e7f664cdb2c94e83d4775f3c59db82fb

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
  • Upload date:
  • Size: 2.5 MB
  • Tags: CPython 3.8, manylinux: glibc 2.5+ i686
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 9d0e0a51c8c45085aafded88441966c2efa850ef7e948c071702cf34d9da8bf6
MD5 3c9094175585643c674080b7325a06b7
BLAKE2b-256 02853093712610744f6d18653bb1ec3bde657046a5c8e34d57aafa785aa6e432

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 183420e85d3d47450a76c2d8047c711d44d07c2d2236d601a318c466fe96090b
MD5 a2721ce3d48d5a12eed7b3bd55a1eeb0
BLAKE2b-256 7dfe3893aafef7f917565ac54a832e3d661f90edf8af950343347cd4365a403e

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.5+ x86-64
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 1592122e1499d114217e1b043bb27bffe7a2d3a68628a639a406501c1f52b06b
MD5 90d97120a53d4d748c526e94d582a791
BLAKE2b-256 7a900e3fd709b1ed5c3f75463a167e2ebcb5000ed9a4258f49abae44d13ada1a

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.5+ i686
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 b8180b2fdf61881fd37b0ca6cf7682556ec351d15bbdad49a88517f1697f2104
MD5 78b9547c10c3480929b147ba85947027
BLAKE2b-256 46e333be96ecdadc647bdc92d8c2ad138b6940946747333ef13becda551ac8f6

See more details on using hashes here.

File details

Details for the file skgrf-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: skgrf-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using 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

File hashes

Hashes for skgrf-0.3.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 de3f3bfbe562dbd3975a1bc4e3aa34e63a51c4dd4c84b23d34be51cad56d3479
MD5 ebf263a46e27658f715825f2a321050d
BLAKE2b-256 b885c6b510ec850b51deec596fdb1175c87c32eba43ef9a4f2cc252049937cce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page