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

Uploaded Source

Built Distributions

skgrf-0.2.0-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.0-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.0-cp39-cp39-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.9macOS 10.15+ x86-64

skgrf-0.2.0-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.0-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.0-cp38-cp38-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.8macOS 10.15+ x86-64

skgrf-0.2.0-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.0-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.0-cp37-cp37m-macosx_10_15_x86_64.whl (2.7 MB view details)

Uploaded CPython 3.7mmacOS 10.15+ x86-64

skgrf-0.2.0-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.0-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.0-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.0.tar.gz.

File metadata

  • Download URL: skgrf-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 aa412f976babeef9be8264e631fd6e0d7b26bde5e25e3a2075ff4828640502e5
MD5 46e05561239be43ff198e505f0d89191
BLAKE2b-256 6ea8ff430d08af9fb1f041962d4d4437a91ceab3d8b3c3643433fd44ca4cc3ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp39-cp39-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 5544dd342c337c7d0d73c918884149189c9f44467e3233741a5ace2b3576af22
MD5 b9756c41e7e8331ab7abded0f21cf441
BLAKE2b-256 841a0e45085e7825cb6ece851ac0491346223efeed8e2987ccb3772440685e15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.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.4.2 importlib_metadata/4.6.4 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.0-cp39-cp39-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 5fa7cc753d3320b6014979af05ebbb02013943aaa45d37dc548e92fb2293caed
MD5 c4264d05e0fd659df1ab7e68362c4cbc
BLAKE2b-256 12b7b2bd96769fea8fa7244f286364885f5f4fd13bd2cdf1e38f8a80b27bd79a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5398387670edd132f538ec2c2393677a1bc876c45ca5cb3f7fe7ca0dc233d028
MD5 898dd6aa9a68ca90651d53e3864365ae
BLAKE2b-256 db91a8a4550d2bb34ffadd8bbc9144974012af7fd782751414b3139c95e3cb18

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp38-cp38-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8a244d5ad8d89e71a73075c0043029a9025807d372f21711208e39bb349d8c32
MD5 6f71aeb13b16d24ad7e747e4054857ba
BLAKE2b-256 489a4faaee4165a8ba043f6d23f4114a1de6cf354ded703106ed30ee75313033

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp38-cp38-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 b16987236e1d917f19486611be6d93fc5d162503c15911a97fe368082faa283c
MD5 411dd2d36541a14a2a8cfe2d59c93840
BLAKE2b-256 0e24fc0edb8edb8fbdeae29be11bc019525fd9398a43b6192c91471683c94fad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp38-cp38-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c3cc18c1377c0ec8ac5694666344c0bfa7f3adf0c2e940b71ff1f8749c889b4c
MD5 90cba62fbb139c94112eefcbeb310195
BLAKE2b-256 e625bd8f210c0d0483ae63376efa359313a456b12107a883d6492bd557c674d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp37-cp37m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c8756343077d96ed78847c0f25ce695251186a615a023352f55896e6519eff6e
MD5 27087a63ad767ea78678ef840fd89a64
BLAKE2b-256 5e812afe59c68c6a0522a1b049478047fc2c9f1dd9bb64e34537dad0051654cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.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.4.2 importlib_metadata/4.6.4 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.0-cp37-cp37m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 c9e3a4fc114c884355e5d9be20af2676ce1560a745d2e0fa426dc51b024a792d
MD5 080dd19838d440c19ea9e408c2930937
BLAKE2b-256 fbf0e7d08250724251864137ca4ffb3d6919d955fcbfb1b774aa29e8af2401f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp37-cp37m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a31eae1af14944bc4a464cb87b340b2d2fbf7a55cb53a376beb0439107b2abf6
MD5 2acdea786796ff28ae7298520a8b907a
BLAKE2b-256 d7f1f27700bbe73d9389956fc23b9be884bd636269fc9b0439aad607d263ab6c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp36-cp36m-manylinux1_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 c685e226304fcb89d3d8db50e58d674ec8fbbbb59a2d2a3840eee2bb5437f066
MD5 1e8aeff1b18d5fb7c435129a8c20b43a
BLAKE2b-256 3c05763807d8a885f4c2de4848bd8f1da4e2b8d718a5bdbb818cd52654c50ec7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp36-cp36m-manylinux1_i686.manylinux_2_5_i686.whl
Algorithm Hash digest
SHA256 10464e0bc5248b1678f1c8a9dd189e5d68d2eff4dbc02e9b16134fe5e3886a74
MD5 1ea3d5ecc34b85839ff2fca5ef176c8d
BLAKE2b-256 f1fa4c769ba22fba28ca729a4664913b9f7b4c6a3c00d2b963da2680a2f28b1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: skgrf-0.2.0-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.6.4 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.0-cp36-cp36m-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e089d89e3b606d310443f6e9ab6335ca6ade435bc5467bb15c8d078bed1e3a3d
MD5 ce5f610cced8d7171ce85eae30988c81
BLAKE2b-256 59da3770102ffc18e565888f9dce31a0feba5f79be60514673e1ae476be86651

See more details on using hashes here.

Supported by

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