A comprehensive implementation of numerical methods for data fitting and interpolation, providing both mathematical implementations and an interactive visualization dashboard.
Numerical Analysis Project implements several mathematical approaches for analyzing relationships between variables, with a focus on ice cream sales data. The project demonstrates both regression techniques (for approximating trends) and interpolation methods (for estimating values between known data points).
This project is part of the course "Numerical Analysis" taught by Prof. Dr. Moisés Dantas. More details about the professor can be found on his LinkedIn profile.
-
Least Squares Regression (MMQ)
- Linear regression model
- Quadratic regression model
-
Interpolation Techniques
- Newton's Divided Differences method
- Lagrange Polynomial method
-
Interactive Dashboard
- Method selection interface
- Parameter adjustment controls
- Real-time visualization of results
-
Comprehensive Visualization
- Plots comparing original data with mathematical models
- Clear visualization of different numerical approaches
- Python 3.11+
- Conda package manager
- Clone the repository to your local machine
- Create and activate the Conda environment:
conda env create -f environment.yml
conda activate numerical-interpolation-methods
To explore specific mathematical implementations:
Least Squares Method (MMQ):
python -m src.mathImplementations.mmq
Lagrange Interpolation:
python -m src.mathImplementations.lagrangeInterpol
Newton's Divided Differences Interpolation:
python -m src.mathImplementations.newtonInterpol
To launch the interactive Gradio dashboard that allows for method selection and parameter adjustment:
python -m src.dasboard.gradio_app
-
src/mathImplementations/
mmq.py: Implementation of Least Squares Method for regressionnewtonInterpol.py: Implementation of Newton's Divided Differences interpolationlagrangeInterpol.py: Implementation of Lagrange Polynomial interpolation
-
src/dashboard/
gradio_app.py: Interactive dashboard for visualizing methods
-
src/utils/
helpers.py: Utility functions for data loading and manipulation
-
data/
ice_cream.csv: Dataset containing temperature and revenue data
The project implements both linear (y = b + a·x) and quadratic (y = b + a·x²) regression models using the Least Squares Method. This approach minimizes the sum of squared differences between observed and predicted values.
Two classic interpolation techniques are implemented:
- Newton's Divided Differences: Builds a polynomial using a recursive formula based on divided differences
- Lagrange Interpolation: Creates a polynomial where each term is constructed to be zero at all data points except one
Both methods produce polynomials that pass exactly through all given data points, but their mathematical formulations and computational approaches differ significantly.
The project uses SymPy to create symbolic mathematical expressions, which are then converted to numerical functions for evaluation and plotting.
Matplotlib is used to generate clear comparisons between original data points and the mathematical models, helping to visualize the effectiveness of different approaches.
The Gradio dashboard provides an intuitive way to:
- Select between different mathematical methods
- Adjust parameters (such as the number of nodes for interpolation)
- Visualize results in real-time
If you encounter issues:
- Verify that the dataset (
data/ice_cream.csv) is present in the correct location - Ensure all dependencies are properly installed via the conda environment
- Check console output for specific error messages
This project was developed as part of the Numerical Analysis course under the guidance of Prof. Dr. Moisés Dantas.