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.2.1.tar.gz (1.8 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

skgrf-0.2.1-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.5+ i686

skgrf-0.2.1-cp39-cp39-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

skgrf-0.2.1-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

skgrf-0.2.1-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl (2.6 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ i686

skgrf-0.2.1-cp38-cp38-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

skgrf-0.2.1-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

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

Uploaded CPython 3.7mmanylinux: glibc 2.5+ i686

skgrf-0.2.1-cp37-cp37m-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

skgrf-0.2.1-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

skgrf-0.2.1-cp36-cp36m-manylinux1_i686.manylinux_2_5_i686.whl (2.6 MB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ i686

skgrf-0.2.1-cp36-cp36m-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.6mmacOS 10.15+ x86-64

File details

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

File metadata

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

File hashes

Hashes for skgrf-0.2.1.tar.gz
Algorithm Hash digest
SHA256 162130bbb7d86c2bbd15cd431f4f37bc2241dd7032b90a675c77710e0ad7d51d
MD5 5881de5cb25f6f8800acad157435e917
BLAKE2b-256 63d09f34722b7c0f84c40e42240937bcccd55c0357c899f1bc99d096e6827254

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 b4d93b2fea2126e25e4d19aa2267d728398365f657ba9d61510653e400a9c425
MD5 cbf5bc7308f55a6e6c1d552c3d181e5f
BLAKE2b-256 32d7f2393c42b693e4d92a11c0b7b5af48733c890185a861d6087ae60cbab255

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 709c27bf74fae21f067580e396234de72360728af19974185203fabb628712a4
MD5 eda2b2e180afdb4320aca0771f5c0e95
BLAKE2b-256 64c9293a7ced580063696ad1ebb70b3baed50401280725d45112afd925f8220c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp39-cp39-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4

File hashes

Hashes for skgrf-0.2.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 8bef628f888dccc0d60b69dc617e4d1520c8a057eb0c170012a3b5a133216d3d
MD5 a4682fdc3a4a553325bb17fadd48c872
BLAKE2b-256 40a71cf37e9c8432b40b6894a8660bcfabbaba1d51253a9d70d9a9cf3e76f1d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.8, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 83299b04841a0f1857c0b61ada572519fb026237947f43918638355cc462c928
MD5 228403796390a219fbafff801d5f44f2
BLAKE2b-256 7508b42309c0e58752f8334fe86a40d0fbfe5bd78950b595420de52a7a7c191a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.8, manylinux: glibc 2.5+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 676ee7ed5c0010ab676ef09ec751890f0f42b6183c75875d4e2e38823e045019
MD5 87b227412be679c9ffc52d6bb8351c39
BLAKE2b-256 fdd408660df3f22d5daa85438ac7fde6d7cb9bc3388ceb22d927fde75bef730a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp38-cp38-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.8, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.9

File hashes

Hashes for skgrf-0.2.1-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 fd1f2dde5bb7d450d7f7ecae17f90d2823735df0c2426d21d021f47996f5bd7d
MD5 a4ab35818d1500d317121445bf46166e
BLAKE2b-256 300e5d53a13e2e0e77152db88d2d7797b73ef937da30bfc9bd13d12472179fbd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.7m, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8247b6e1556fd1160879f30424e6dc9e2c4133bfa2db46448776741c7da1cbdd
MD5 bea64840b04d8b7fcd1b49d933ef5877
BLAKE2b-256 20e49fd8fd955cf668888028c9245671ede039d5f00d108aed45f180a4214ad2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-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.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 a6123a7769403e44859ae6cbeb6957f68eab5273ac5657291f9c7dacc890d65f
MD5 65d326a7faf59200ae8e606cdd419540
BLAKE2b-256 ff335c463ef6cb4faa9b00160c8795250c43f8366765e6b2152be1aa2e78fa27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.1-cp37-cp37m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.7m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.7.9

File hashes

Hashes for skgrf-0.2.1-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 79e6687bcad0a45fd84ce6356623090c73163bf80d3da88333c75c2c02b50f38
MD5 eba6e83ccdfb50709f90b7343ee0ecbe
BLAKE2b-256 cc650db553ad042a3a57f5a88f15765c6f177e4cdfeb78449a99c21a2fa042cb

See more details on using hashes here.

File details

Details for the file skgrf-0.2.1-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.whl.

File metadata

  • Download URL: skgrf-0.2.1-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.5+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 a3c65449eb044b81c1860af556a384591d9a05f3ed3a44bbc1b53358b38ee604
MD5 78703309be1ef172dbfae3ce8c444852
BLAKE2b-256 3b62ed545640de9a391bfa6e80c6facc8b8fedc48ecdbbbeaf387a7fcd8b1eca

See more details on using hashes here.

File details

Details for the file skgrf-0.2.1-cp36-cp36m-manylinux1_i686.manylinux_2_5_i686.whl.

File metadata

  • Download URL: skgrf-0.2.1-cp36-cp36m-manylinux1_i686.manylinux_2_5_i686.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: CPython 3.6m, manylinux: glibc 2.5+ i686
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10

File hashes

Hashes for skgrf-0.2.1-cp36-cp36m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 f5be7ca9b8d515c6cfca744cacc2938f571279974da0ea8d771ed47572fb1d37
MD5 d57801501c187f6d1b715afa81e60e0c
BLAKE2b-256 8bae02d664ddc9a06c93ed51cd1edbbb84956b6ac6e2007ba224a9634d649ce7

See more details on using hashes here.

File details

Details for the file skgrf-0.2.1-cp36-cp36m-macosx_10_15_x86_64.whl.

File metadata

  • Download URL: skgrf-0.2.1-cp36-cp36m-macosx_10_15_x86_64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.6m, macOS 10.15+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.6.8

File hashes

Hashes for skgrf-0.2.1-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3f13ee63c11e82e49859bb39e0226c97200928b7104a900d4a92d0192a3e63d3
MD5 50aeaef4fa8c014b82da11fc5e24a930
BLAKE2b-256 98017a394b8debb0148e1798066cfe91086fef122c569766cda3419b231e955c

See more details on using hashes here.

Supported by

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