Skip to main content

PyPI version Supported Python versions Licence

orf: ordered random forests

Welcome to the repository of the Python package orf for random forest estimation of the ordered choice models. For the R version of the orf package Lechner and Okasa (2020) please refer to the CRAN repository.

Introduction

The Python package orf is an implementation of the Ordered Forest estimator as developed in Lechner and Okasa (2019). The Ordered Forest flexibly estimates the conditional probabilities of models with ordered categorical outcomes (so-called ordered choice models). Additionally to common machine learning algorithms the Ordered Forest provides functions for estimating marginal effects and thus provides similar output as in standard econometric models for ordered choice. The core Ordered Forest algorithm relies on the fast forest implementation from the scikit-learn (Pedregosa et al., 2011) library.

Installation

In order to install the latest PyPi released version run

pip install orf

in the terminal. orf requires the following dependencies:

  • numpy (>=1.21.0)
  • pandas (>=1.3.5)
  • scipy (>=1.7.2)
  • scikit-learn (>=1.0.2)
  • joblib (>=1.0.1)
  • plotnine (>=0.8.0)

In case of an installation failure due to dependency issues or conflicts with Anaconda distribution, consider installing the package in a virtual environment.

The implementation relies on Python 3 and is compatible with version 3.8, 3.9 and 3.10.

Examples

The example below demonstrates the basic functionality of the Ordered Forest.

## Ordered Forest
import orf

# load example data
features, outcome = orf.make_ordered_regression()

# initiate Ordered Forest with custom settings
oforest = orf.OrderedForest(n_estimators=1000, min_samples_leaf=5,
                            max_features=2, replace=False, sample_fraction=0.5,
                            honesty=True, honesty_fraction=0.5, inference=False,
                            n_jobs=-1, random_state=123)

# fit Ordered Forest
oforest.fit(X=features, y=outcome)

# show summary of the Ordered Forest estimation
oforest.summary()

# evaluate the prediction performance
oforest.performance()

# plot the estimated probability distributions
oforest.plot()

# predict ordered probabilities in-sample
oforest.predict(X=None, prob=True)

# evaluate marginal effects for the Ordered Forest
oforest.margins(X=None, X_cat=None, X_eval=None, eval_point='mean', window=0.1)

For more detailed examples see the package description.

References

The orf logo has been created via R-package hexSticker using Tourney font designed by Tyler Finck, ETC.

Metadata

Release files for orf 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for orf 0.2.0
File Size Uploaded Provenance Actions
orf-0.2.0.tar.gz 29.9 kB Without provenance Details for orf-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for orf 0.2.0
File Interpreter ABI Platform Actions
orf-0.2.0-py3-none-any.whl Python 3 none any Details for orf-0.2.0-py3-none-any.whl

Total release size: 60.9 kB

Release files / orf-0.2.0.tar.gz

Download URL orf-0.2.0.tar.gz
Size 29.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ef9ae8b3efa8b7e8d05e3d7a1bb32760516019407f038ad7c387792128978c81
BLAKE2b-256 checksum
How to use checksums
7085b6ca6e596ec73a91a93e6ccdfccf114e6edfde1a2ea87f799a811757ad78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Release files / orf-0.2.0-py3-none-any.whl

Download URL orf-0.2.0-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7124f13def41110ab4363e78a40272d3f7aa160852e82f11ca4ca08e98576077
BLAKE2b-256 checksum
How to use checksums
533c1554fd9ac46ace3ebb8b60cebf3d680232fbfaf3bbbf6dac03bb48f4a7fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.7

Security for orf 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page