Mission Statement
"My mission is to implement various mathematical algorithms in Python for practice, to test my skills, to document the methods, and just for fun"
Project Summary
During my third year of post secondary, I learnt a ton of algorithms for solving problems in my numerical analysis course, however I have only implemented them in MATLAB thus-far. Hence: my goal here is to implement algorithms - including but not limited to Newtons Method, the Bisection Method, Lagrange Interpolation, Trapezoid & Simpsons Integration, & Lipchitz Algorithm, as well as Euler's & Heun's Methods for approximating ODE's - in Python. Also Just for fun im going to sprinkle in some of my own creations i've wanted for a while - such as using multiple regression techniques to find the best fit function on a dataset.
And the current Iteration after that involves Forior series regression by computing a best fit function as multiple functions summed together (which can be done by regressing on the error terms) - which theoretically could mean the error of a graph could be chocked up to a sinosudial term in the true function
The Goal here? I would like to ultimately bridge this section of the project into an open source library/package to serve as an aditional tool in our workforces data science toolboxes
First, install the dependecies:
pip install numpy pandas seaborn matplotlib statsmodels sympy
Next, prepare your data with an independent & dependent variabke: example CSV:
age, length
15, 5.1
16, 5.3
17, 5.6
Then you can run the script:
Save the script (Plot_Finder.py) to your local machine, & append this to a Python file's import section
from Plot_Finder import find_best_fit
import pandas as pd
& finally, run find_best_fit(x, y)
on your data, Plot Finder will provide a similar output to:
--- Regression Errors ---
Linear Error: 2.5064127927953335
Quadratic Error: 2.376293313469839
Cubic Error: 2.3306552613010023
Exponential Error: 2.5033863710624638
Logarithmic Error: 2.408240048405719
Sine Error: 2.5278577442576977
LOESS Error: 3.5317500644855344
Polynomial (x^4) Error: 2.3629127943906134
Polynomial (x^5) Error: 2.3953673780927542
Polynomial (x^6) Error: 2.357742781477933
Polynomial (x^7) Error: 2.3560983113517175
The method with the smallest error is: Cubic Regression with an error of 2.3306552613010023
Approximate function: 0.0436070723456402*x**3 - 0.787115855407833*x**2 + 4.5685444988691*x + 85.1575254621457
plotting: 0.0436070723456402*x**3 - 0.787115855407833*x**2 + 4.5685444988691*x + 85.1575254621457
and give you a plot to vizualize the data & regression line provided,
this project aims to be expanded into an open-source library with additional features, including:
Contributions to improve the script or add new features are welcome! Feel free to fork the repository and submit pull requests.