Skip to main content

Probabilistic Predictions

Project description

https://img.shields.io/pypi/v/pysloth Documentation Status https://github.com/PySloth/pysloth/actions/workflows/build-and-tests.yml/badge.svg https://codecov.io/gh/PySloth/pysloth/branch/main/graph/badge.svg?token=gAMTe66DIg

pysloth

A Python package for Probabilistic Prediction

v0.0.3

Installation

This package supports Python 3.6, 3.7, 3.8, and 3.9

Install via PyPI

Run pip install pysloth

Install from repository

  • Clone repo with SSH git clone git@github.com:PySloth/pysloth.git

  • Change directory to where README.md (this file) is located and run pip install .

Quickstart

The following is a code sample showing scpd and ccpd in action

from pysloth import scpd_function, ccpd_function

import numpy as np
import statsmodels.api as sm

np.random.seed(142)
n = 1000  # training set
m = int(0.8 * n)  # proper training set
n_cal = n - m  # Calibration = training - proper training

n_test = 100
sd_noise = 1

n_delta = 1000  # discretization for y values in interval y_hat +/- 3 * delta
w = 2  # the weights

x_train = w * np.random.random(m) - 1
x_cal = w * np.random.random(n_cal) - 1
x_test = w * np.random.random(n_test) - 1

y_train = w * x_train + np.random.randn(m) * sd_noise
y_cal = w * x_cal + np.random.randn(n_cal) * sd_noise
y_test = w * x_test + np.random.randn(n_test) * sd_noise

x_train_cal = np.reshape(np.hstack((x_train, x_cal)), (n, 1))
y_train_cal = np.reshape(np.hstack((y_train, y_cal)), (n, 1))
xy_train_cal = np.hstack((x_train_cal, y_train_cal))

model = sm.OLS(y_train, x_train).fit()
predictions = model.predict(x_train)
model.summary()
y_hat = model.predict(x_test)

delta = 3 * np.std(y_hat)
y_grid = np.linspace(y_hat.min() - delta, y_hat.max() + delta, n_delta)

print(ccpd_function(x_train_cal, y_train_cal, x_test, y_grid, 5, n_delta))
print(scpd_function(x_train, x_cal, y_train, y_cal, x_test, y_test, y_grid, 5, n_delta))

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

pysloth-0.0.3.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

pysloth-0.0.3-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pysloth-0.0.3.tar.gz.

File metadata

  • Download URL: pysloth-0.0.3.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for pysloth-0.0.3.tar.gz
Algorithm Hash digest
SHA256 ff3cce6403b33a71c07559604d500a72de91a7cfabe5ea49d5badf6beb4e689e
MD5 6d25ec6c143177bbcc9a293030262e3e
BLAKE2b-256 efeb8c1f12599c64e4c975e77c652ea48be2165002f7c139b30984d937cf5d0c

See more details on using hashes here.

File details

Details for the file pysloth-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pysloth-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for pysloth-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 59f7d53e84d803a939cefd33bd09188115e6d847326f32da73ad086e1c23d016
MD5 41351a2808bc90cc53ce764dd30aab80
BLAKE2b-256 d7f2bf84853d5a496022ec725f36070446a6948549c36bb83c029c853f157c78

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