Skip to main content

Generate regression models from data

Reason this release was yanked:

Flaw with installation

Project description

Regressions

Generates Multiple Statistical Regression Models for Data Sets

The regressions library is a collection of algorithms for fitting data to different functional models by using linear algebra and machine learning. It can generate the following eight key regression models based on any data set: linear, quadratic, cubic, hyperbolic, exponential, logarithmic, logistic, and sinusoidal. For each model, it outputs the constants of the equation, notable graphical points, and the correlation coefficient, among other useful details. For more information, view the library's full code base to understand how it works or its documentation to master the nuances of its usage.

Requirements

  • Python 3.8 or higher
  • NumPy
  • SciPy

Installation

pip3 install regressions

Usage

from regressions.execute import run_all # Import function to generate all models

data_set = [[1, 32], [2, 25], [3, 14], [4, 23], [5, 39], [6, 45], [7, 42], [8, 49], [9, 36], [10, 33]] # Create data set to test
results = run_all(data_set) # Generate all models for data set

linear = results['models']['linear'] # Grab specifics for linear model
linear_constants = linear['constants'] # Grab constants of equation for linear model
print(linear_constants) # [1.9636, 23.0]
linear_correlation = linear['correlation'] # Grab correlation coefficient for linear model
print(linear_correlation) # 0.5516

quadratic = results['models']['quadratic'] # Grab specifics for quadratic model
quadratic_constants = quadratic['constants'] # Grab constants of equation for quadratic model
print(quadratic_constants) # [-0.3106, 5.3803, 16.1667]
quadratic_correlation = quadratic['correlation'] # Grab correlation coefficient for quadratic model
print(quadratic_correlation) # 0.5941

cubic = results['models']['cubic'] # Grab specifics for cubic model
cubic_constants = cubic['constants'] # Grab constants of equation for cubic model
print(cubic_constants) # [-0.3881, 6.0932, -24.155, 49.4667]
cubic_correlation = cubic['correlation'] # Grab correlation coefficient for cubic model
print(cubic_correlation) # 0.8933

hyperbolic = results['models']['hyperbolic'] # Grab specifics for hyperbolic model
hyperbolic_constants = hyperbolic['constants'] # Grab constants of equation for hyperbolic model
print(hyperbolic_constants) # [-13.5246, 37.7613]
hyperbolic_correlation = hyperbolic['correlation'] # Grab correlation coefficient for hyperbolic model
print(hyperbolic_correlation) # 0.3479

exponential = results['models']['exponential'] # Grab specifics for exponential model
exponential_constants = exponential['constants'] # Grab constants of equation for exponential model
print(exponential_constants) # [22.1049, 1.0692]
exponential_correlation = exponential['correlation'] # Grab correlation coefficient for exponential model
print(exponential_correlation) # 0.5069

logarithmic = results['models']['logarithmic'] # Grab specifics for logarithmic model
logarithmic_constants = logarithmic['constants'] # Grab constants of equation for logarithmic model
print(logarithmic_constants) # [7.4791, 22.5032]
logarithmic_correlation = logarithmic['correlation'] # Grab correlation coefficient for logarithmic model
print(logarithmic_correlation) # 0.5086

logistic = results['models']['logistic'] # Grab specifics for logistic model
logistic_constants = logistic['constants'] # Grab constants of equation for logistic model
print(logistic_constants) # [43.983, 0.3076, 0.9746]
logistic_correlation = logistic['correlation'] # Grab correlation coefficient for logistic model
print(logistic_correlation) # 0.5875

sinusoidal = results['models']['sinusoidal'] # Grab specifics for sinusoidal model
sinusoidal_constants = sinusoidal['constants'] # Grab constants of equation for sinusoidal model
print(sinusoidal_constants) # [14.0875, 0.7119, -3.7531, 34.2915]
sinusoidal_correlation = sinusoidal['correlation'] # Grab correlation coefficient for sinusoidal model
print(sinusoidal_correlation) # 0.9264

optimal = results['optimal']['option'] # Grab name of model with highest correlation coefficient
print(optimal) # 'sinusoidal'

Testing

There are currently 1276 tests for this library. To run all of them:

  1. Clone this repository: git clone https://github.com/jtreeves/regressions_library.git
  2. Enter the directory: cd regressons_library
  3. Run tests: python3 -m unittest

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

regressions-2.0.3.tar.gz (101.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

regressions-2.0.3-py2-none-any.whl (147.0 kB view details)

Uploaded Python 2

File details

Details for the file regressions-2.0.3.tar.gz.

File metadata

  • Download URL: regressions-2.0.3.tar.gz
  • Upload date:
  • Size: 101.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for regressions-2.0.3.tar.gz
Algorithm Hash digest
SHA256 c2bf7207af0e7c9aec56570befb803b686fe54c917683b3f064231da21f03035
MD5 278741d820c30000480628069af8b0be
BLAKE2b-256 a9f8fb932c109835ba181f41e3fd1d44c28e9e1e3803f0e83be463133ca3204e

See more details on using hashes here.

File details

Details for the file regressions-2.0.3-py2-none-any.whl.

File metadata

  • Download URL: regressions-2.0.3-py2-none-any.whl
  • Upload date:
  • Size: 147.0 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for regressions-2.0.3-py2-none-any.whl
Algorithm Hash digest
SHA256 e11c50d067340e287be5b1683caf3925c45cdd439bb0a5af3220289e1df58d40
MD5 bfcb2853f932600459cc43b2ec4933b5
BLAKE2b-256 c8f255e165aedea5a1c8f86144e5e8b4a2d5f47a4e6f2567b821e43d52342c8c

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