Skip to main content

No project description provided

Project description

prfr

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

Installation

pip install prfr

OR

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

Example usage

import numpy as np
from prfr import ProbabilisticRandomForestRegressor, split_arrays

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 = split_arrays(x_obs, y_obs, x_err, y_err, test_size=0.2, valid_size=0.2)

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

pred = model.predict(x_test, eX=x_err_test)
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.1.5.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

prfr-0.1.5-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: prfr-0.1.5.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b1 CPython/3.10.2 Linux/5.18.5-arch1-1

File hashes

Hashes for prfr-0.1.5.tar.gz
Algorithm Hash digest
SHA256 807ffd06aca9e12f328d30a81cad5b9ed4ae95d2a4d723eed9450d76be9583d3
MD5 f7cee7d2c201f306491bfed24ca07bab
BLAKE2b-256 75a5c78ed1fcce3e632d0466a2e4c256f2c2fff126447093c494c9c82edd5dfa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: prfr-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0b1 CPython/3.10.2 Linux/5.18.5-arch1-1

File hashes

Hashes for prfr-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 bab3ce18f6b627a322eb80eb36bda8364a803a71c7ea7e72437b6a7d5d858fd2
MD5 09d4a10a4bd86bc977622609335434f2
BLAKE2b-256 720327f6592da26b20b0fe93b961dcaac065d62fe9339c8556d17b2796f9aab4

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