Skip to main content

Machine learning model that uses linear regression equations in the leaf nodes of a decision tree.

Project description

py-plrt

This package combines two widely used and interpretable machine learning algorithms (Decision Trees and Linear Regression) to create Piece-Wise Linear Regression Trees (PLRTs). This idea is introduced by Alexander and Grimshaw (1996).

Decision Trees are non-parametric, supervised learning methods that split the data at a specific threshold for a specific feature to optimize a loss function (e.g. mean square error (MSE)). Linear regression is a parametric, supervised learning method that uses a linear combination of a set of features to predict a response variable.

Decision Trees typically predict the mean of the response variable in a particular leaf. Models that predict the mean are often referred to as the "Null Model" for a particular dataset. Replacing the mean prediction with a linear regression formulation for each leaf helps capture linear dependencies between features and the response variable, thus improving the accuracy of the model. This also ensures that the final model is a "white-box" model because the steps taken to arrive at a solution are available and interpretable. Combining a decision tree on top of several linear regression formulations and fitting them together results in data being separated into groups that can be described by linear relationships the best, thus acting as a faux classification layer.

Portions of this package are inspired by the DecisionTreeRegressor from scikit-learn and the Regression Tree in Python From Scratch article by Eligijus Bujokas. Visualization methods are adapted from treelib.

Installation

Install py-plrt with pip: pip install py-plrt

Clone the repository and install a local version:

git clone https://github.com/lcford2/py-plrt.git
cd py-plrt
pip install -e .

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

py-plrt-0.0.4.tar.gz (10.2 kB view details)

Uploaded Source

File details

Details for the file py-plrt-0.0.4.tar.gz.

File metadata

  • Download URL: py-plrt-0.0.4.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for py-plrt-0.0.4.tar.gz
Algorithm Hash digest
SHA256 8d0b375702ac551cd9c99fd8f0f12d87717e4616d9b49d2f9e83689708c3f71c
MD5 269ac5993668a5c1c47e4bfc25d85dae
BLAKE2b-256 6311fcdc3085299b562bcc277fac669479deb1783289cc98815ba74c6522790f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page