Skip to main content

Probabilitic random forest regression algorithm

Project description

prfr

Probabilistic random forest regressor: random forest model that accounts for errors in predictors and labels, yields calibrated probabilistic predictions, and corrects for bias.

For a faster and more elaborate calibration routine (highly recommended), a JAX installation is required. You can install the package with the extra jax feature, which will install the necessary dependencies.

Installation

From PyPI, with jax feature:

pip install "prfr[jax]" 

From PyPI, without jax feature:

pip install prfr

From Github (latest), with jax feature:

pip install "prfr[jax] @ git+https://github.com/al-jshen/prfr"

From Github (latest), without jax feature:

pip install "git+https://github.com/al-jshen/prfr"

Example usage

import numpy as np
import prfr

x_obs = np.random.uniform(0., 10., size=10000).reshape(-1, 1)
x_err = np.random.exponential(1., size=10000).reshape(-1, 1)
y_obs = np.random.normal(x_obs, x_err).reshape(-1, 1) * 2. + 1.
y_err = np.ones_like(y_obs)

train, test, valid = prfr.split_arrays(x_obs, y_obs, x_err, y_err, test_size=0.2, valid_size=0.2)

model = prfr.ProbabilisticRandomForestRegressor(n_estimators=250, n_jobs=-1)
model.fit(train[0], train[1], eX=train[2], eY=train[3])
model.fit_bias(valid[0], valid[1], eX=valid[2])

# check whether the calibration routine will run with JAX
print(prfr.has_jax)

model.calibrate(valid[0], valid[1], eX=valid[2])

pred = model.predict(test[0], eX=test[2])
pred_qtls = np.quantile(pred, [0.16, 0.5, 0.84], axis=-1)

print(pred.shape)

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

prfr-0.2.2.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

prfr-0.2.2-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file prfr-0.2.2.tar.gz.

File metadata

  • Download URL: prfr-0.2.2.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.4 Darwin/21.4.0

File hashes

Hashes for prfr-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f5aed3f5c8ad58aec877fbdf64cf94ce6af716f71cf289488643b83743cb42bb
MD5 8d23d1383dc7975dac96e0c346115f12
BLAKE2b-256 d4d1c8ee624b49eb4c4a5582bc7d60a8712ffde967b90f46f24616abf227f63b

See more details on using hashes here.

File details

Details for the file prfr-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: prfr-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.2 CPython/3.10.4 Darwin/21.4.0

File hashes

Hashes for prfr-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f2951a4b06f1c9b0978e9a6cda35633fe3629b09233859b2ccfbf7ed9acebfa
MD5 5865177152c462f97d418ec58b5f703b
BLAKE2b-256 48ec0964a73660dd9f9512097b0715122e91feec0c47d035497370f18baa5b42

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