A Python program that analyzes historical sea level data and visualizes it using scatter plots with linear regression lines. The project predicts future sea level trends using two lines of best fit: one based on all available data, and another using data from the year 2000 onward.
- Reads sea level data from a CSV file.
- Creates a scatter plot of historical sea level measurements.
- Adds a line of best fit for all years (1880–2050 prediction).
- Adds a line of best fit for recent years (2000–2050 prediction) to highlight accelerated trends.
- Saves the plot as a PNG image.
Before running this project, ensure you have:
- Python 3.8+
- Pandas, Matplotlib, SciPy libraries
- CSV dataset epa-sea-level.csv inside a data folder
- Basic understanding of Python and plotting
- Clone the repository:
git clone https://github.com/radwanhefny/Sea-Level-Predictor.git
cd Sea-Level-Predictor
- Install dependencies:
pip install -r requirements.txt- Run the visualization scripts:
python main.py📁 Sea-Level-Predictor
├── main.py
├── sea_level_predictor.py # Core calculations and plotting
├── data/
│ └── epa-sea-level.csv # Dataset
├── examples/
│ ├── Figure_1.png # Scatter plot with best fit lines
│ └── Result_1.png # Final plotted result
├── requirements.txt
├── test_module.py
└── README.md
Example usage inside Python:
from sea_level_predictor import draw_plot
plot_ax = draw_plot()
plot_ax.figure.show()
Expected output:
- sea_level_plot.png → Scatter plot of sea level data with two lines of best fit
Run the FreeCodeCamp test suite:
python test_module.py- Reads the CSV dataset using Pandas.
- Creates a scatter plot of historical sea levels.
- Computes two lines of best fit using linear regression:
- One for all years
- One for years 2000 onward
- Extends the lines to 2050 to visualize future trends.
- Saves the final plot as a PNG image for reporting or analysis.
Contributions are welcome!
- Fork the repository
- Create a new feature branch
- Submit a pull request Please ensure your code is clean, structured, and well-commented.
This project is licensed under the MIT license - see the LICENSE file for details.
If you have questions or need help, feel free to:
- Open an issue on this repository
- Connect with me on LinkedIn: https://www.linkedin.com/in/radwanhefny
