Skip to main content

Engression

Project description

Engression

Engression is a nonlinear regression methodology proposed in the paper "Engression: Extrapolation for Nonlinear Regression?" by Xinwei Shen and Nicolai Meinshausen. This directory contains the Python implementation of engression.

Installation

The latest release of the Python package can be installed through pip:

pip install engression

The development version can be installed from github:

pip install -e "git+https://github.com/xwshen51/engression#egg=engression&subdirectory=engression-python" 

Usage Example

Python

Below is one simple demonstration. See this tutorial for more details on simulated data and this tutorial for a real data example.

from engression import engression
from engression.data.simulator import preanm_simulator

## Simulate data
x, y = preanm_simulator("square", n=10000, x_lower=0, x_upper=2, noise_std=1, train=True, device=device)
x_eval, y_eval_med, y_eval_mean = preanm_simulator("square", n=1000, x_lower=0, x_upper=4, noise_std=1, train=False, device=device)

## Fit an engression model
engressor = engression(x, y, lr=0.01, num_epoches=500, batch_size=1000, device="cuda")
## Summarize model information
engressor.summary()

## Evaluation
print("L2 loss:", engressor.eval_loss(x_eval, y_eval_mean, loss_type="l2"))
print("correlation between predicted and true means:", engressor.eval_loss(x_eval, y_eval_mean, loss_type="cor"))

## Predictions
y_pred_mean = engressor.predict(x_eval, target="mean") ## for the conditional mean
y_pred_med = engressor.predict(x_eval, target="median") ## for the conditional median
y_pred_quant = engressor.predict(x_eval, target=[0.025, 0.5, 0.975]) ## for the conditional 2.5% and 97.5% quantiles

Contact information

If you meet any problems with the code, please submit an issue or contact Xinwei Shen.

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

engression-0.0.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

engression-0.0.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file engression-0.0.1.tar.gz.

File metadata

  • Download URL: engression-0.0.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for engression-0.0.1.tar.gz
Algorithm Hash digest
SHA256 da159f4222c8672d9a4f69a2ace014c8e62adea4adbdfb93453735d0ae52e3af
MD5 3894c3e4bbd67d2cce3307d4c24792ca
BLAKE2b-256 2dafd00eeedbad88a06fb41a17702c3ba76cdddd449ae3a189070ea24305b4ea

See more details on using hashes here.

File details

Details for the file engression-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: engression-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for engression-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7619590c4af963ff181f62634cae2d4f5b12319393530f1a248ed61f1e2516f
MD5 66a0a35b59cc699193a3b1623c718519
BLAKE2b-256 d3e3f5bdb38a0e74c70d56289c7fb8049c119d7931e2d3dcc7905b022d97a279

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