Package: regressions
RegressionsThe 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 fullcode baseto understand how it works or itsdocumentationto master the nuances of its usage.RequirementsPython 3.8 or higherNumPySciPyInstallationpip3 install regressionsUsagefromregressions.executeimportrun_all# Import function to generate all modelsdata_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 testresults=run_all(data_set)# Generate all models for data setlinear=results['models']['linear']# Grab specifics for linear modellinear_constants=linear['constants']# Grab constants of equation for linear modelprint(linear_constants)# [1.9636, 23.0]linear_correlation=linear['correlation']# Grab correlation coefficient for linear modelprint(linear_correlation)# 0.5516quadratic=results['models']['quadratic']# Grab specifics for quadratic modelquadratic_constants=quadratic['constants']# Grab constants of equation for quadratic modelprint(quadratic_constants)# [-0.3106, 5.3803, 16.1667]quadratic_correlation=quadratic['correlation']# Grab correlation coefficient for quadratic modelprint(quadratic_correlation)# 0.5941cubic=results['models']['cubic']# Grab specifics for cubic modelcubic_constants=cubic['constants']# Grab constants of equation for cubic modelprint(cubic_constants)# [-0.3881, 6.0932, -24.155, 49.4667]cubic_correlation=cubic['correlation']# Grab correlation coefficient for cubic modelprint(cubic_correlation)# 0.8933hyperbolic=results['models']['hyperbolic']# Grab specifics for hyperbolic modelhyperbolic_constants=hyperbolic['constants']# Grab constants of equation for hyperbolic modelprint(hyperbolic_constants)# [-13.5246, 37.7613]hyperbolic_correlation=hyperbolic['correlation']# Grab correlation coefficient for hyperbolic modelprint(hyperbolic_correlation)# 0.3479exponential=results['models']['exponential']# Grab specifics for exponential modelexponential_constants=exponential['constants']# Grab constants of equation for exponential modelprint(exponential_constants)# [22.1049, 1.0692]exponential_correlation=exponential['correlation']# Grab correlation coefficient for exponential modelprint(exponential_correlation)# 0.5069logarithmic=results['models']['logarithmic']# Grab specifics for logarithmic modellogarithmic_constants=logarithmic['constants']# Grab constants of equation for logarithmic modelprint(logarithmic_constants)# [7.4791, 22.5032]logarithmic_correlation=logarithmic['correlation']# Grab correlation coefficient for logarithmic modelprint(logarithmic_correlation)# 0.5086logistic=results['models']['logistic']# Grab specifics for logistic modellogistic_constants=logistic['constants']# Grab constants of equation for logistic modelprint(logistic_constants)# [43.9838, 0.3076, 0.9747]logistic_correlation=logistic['correlation']# Grab correlation coefficient for logistic modelprint(logistic_correlation)# 0.5875sinusoidal=results['models']['sinusoidal']# Grab specifics for sinusoidal modelsinusoidal_constants=sinusoidal['constants']# Grab constants of equation for sinusoidal modelprint(sinusoidal_constants)# [14.0875, 0.7119, -3.7531, 34.2915]sinusoidal_correlation=sinusoidal['correlation']# Grab correlation coefficient for sinusoidal modelprint(sinusoidal_correlation)# 0.9264optimal=results['optimal']['option']# Grab name of model with highest correlation coefficientprint(optimal)# 'sinusoidal'Recent Updatesas of version 2.1.0 (released 05/16/21)Logistic models with higher correlation coeffients on averageSinusoidal models with notes about their key graphical features iin which their general forms include only a plus sign before the periodic unit as opposed to both plus and minus signs in some casesTo see all updates by version number, view theRelease Notes sectionof its documentation.To see all logs for the library, view itscommit historyon GitHub.TestingThere are currently 1445 tests for this library. To run all of them:Clone this repository:git clone https://github.com/jtreeves/regressions_library.gitEnter the directory:cd regressons_libraryRun tests:python3 -m unittest