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

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) * 2. + 1.

train_arrays, test_arrays, valid_arrays = split_arrays(x_obs, x_err, y_obs, test_size=0.2, valid_size=0.2)
x_train, x_err_train, y_train = train_arrays
x_test, x_err_test, y_test = test_arrays
x_valid, x_err_valid, y_valid = valid_arrays

model = ProbabilisticRandomForestRegressor(n_estimators=250, n_jobs=-1)
model.fit(x_train, y_train, eX=x_err_train)
model.calibrate(x_valid, y_valid, eX=x_err_valid)
model.fit_bias(x_valid, y_valid, eX=x_err_valid)

pred = model.predict(x_test, eX=x_err_test)
pred_bounds = np.quantile(pred, [0.16, 0.84], axis=1)
pred_mean = np.mean(pred, 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.2.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

prfr-0.1.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for prfr-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ed33bddd1281bff9b9c7e91c1c4e6a84d8d6da0bdcd068f6ec8065f3be9a346d
MD5 7320b0f16c005d1e722d69bd6c3cafd1
BLAKE2b-256 63c3b9b4e0c65d65c4175e873e7b7e32b138237aa6373792dfa9fcdef4150d80

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for prfr-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 be8df96faf5b6f4b21210334fa313bcbcd0acd3ba29b89e6b7831ca5667d76cc
MD5 63c2277bed5805482d2fc3e39cfe8c6c
BLAKE2b-256 d72bf0fe7ceae145ab7e9853615fb0342b1d365fc541ef1e82bb07304fbda492

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