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
Release history Release notifications | RSS feed
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.4.tar.gz
(12.4 kB
view details)
Built Distribution
prfr-0.1.4-py3-none-any.whl
(12.3 kB
view details)
File details
Details for the file prfr-0.1.4.tar.gz
.
File metadata
- Download URL: prfr-0.1.4.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f234e9c589675b041c88beaf1c5e20df1f821293a9319112c9ccd47fa6a1ed5 |
|
MD5 | 17f4e13d68dccf60c381bf6b31e90de4 |
|
BLAKE2b-256 | ffc9a5ddfeae385b76349153d5bc241c5cfeba33b2985e84dc7338a54527ad2a |
File details
Details for the file prfr-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: prfr-0.1.4-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.12 Darwin/21.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cc9a108a88047affe7c59c417446f0f085185429c5388c98557f8d3f1509237 |
|
MD5 | 20ff66b925a160642d50372352f31cf1 |
|
BLAKE2b-256 | 6a22be0cb75f9a2c328d5a7292d2fd5b7de4f2ad6f38ccedf670fe1ec09b7d11 |