Sea Level Predictor
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Chris DiCarlo d23928ece0
fixed test_plot_data_points and test_plot_lines (#3)
* Fixed test_plot_data_points to match given data

Some of the expected values in test_plot_data_points have extra digits.  The second data point had a y value of 0.22047244100000002 instead of 0.220472441 as given in the csv data file.  These cause errors with assertEqual.  It works fine with just this change, but it is still checking floats for equality which could be brittle. I also modified the assert line to use np.testing.assert_almost_equal which checks lists in an element-by-element fashion with tolerance and should be more robust.

* fixed test_plot_lines

Question asks for regression line "Through the year 2050" but the expected lists stops at the y-value for 2049.  Added datapoint for 2050 in both lines.  assertEqual was throwing errors for differences in 10th digit, changing this to np.testing.assert_almost_equal checks the first 7 digits which is a more robust way to check a regression calculated value.

* Added numpy import at top

added numpy import at top for np.testing.assert_almost_equal
3 years ago
.replit feat: add replit config (#1) 4 years ago
README.md Fixing typo: scipi should be scipy (#5) 3 years ago
epa-sea-level.csv init 4 years ago
main.py init 4 years ago
poetry.lock init 4 years ago
pyproject.toml feat: add description to pyproject.toml (#2) 4 years ago
sea_level_predictor.py init 4 years ago
test_module.py fixed test_plot_data_points and test_plot_lines (#3) 3 years ago

README.md

Assignment

You will anaylize a dataset of the global average sea level change since 1880. You will use the data to predict the sea level change through year 2050.

Use the data to complete the following tasks:

  • Use Pandas to import the data from epa-sea-level.csv.
  • Use matplotlib to create a scatter plot using the "Year" column as the x-axis and the "CSIRO Adjusted Sea Level" column as the y-axix.
  • Use the linregress function from scipy.stats to get the slope and y-intercept of the line of best fit. Plot the line of best fit over the top of the scatter plot. Make the line go through the year 2050 to predict the sea level rise in 2050.
  • Plot a new line of best fit just using the data from year 2000 through the most recent year in the dataset. Make the line also go through the year 2050 to predict the sea level rise in 2050 if the rate of rise continues as it has since the year 2000.
  • The x label should be "Year", the y label should be "Sea Level (inches)", and the title should be "Rise in Sea Level".

Unit tests are written for you under test_module.py.

Development

For development, you can use main.py to test your functions. Click the "run" button and main.py will run.

Testing

We imported the tests from test_module.py to main.py for your convenience. The tests will run automatically whenever you hit the "run" button.

Submitting

Copy your project's URL and submit it to freeCodeCamp.

Data Source

Global Average Absolute Sea Level Change, 1880-2014 from the US Environmental Protection Agency using data from CSIRO, 2015; NOAA, 2015. https://datahub.io/core/sea-level-rise