# Sea Level Predictor Project

Tell us what’s happening:
I am trying to add the entry for 2050 year as mentioned in the project. But somehow the even though I have added the entry the test case fails with following error:

self.assertEqual(actual, expected, “Expected different line for first line of best fit.”)
AssertionError: Lists differ: [-0.5[2613 chars]87559] != [-0.5[2613 chars]87559, 7.905850232699706, 7.968894816711838, 8[634 chars]2443]

Second list contains 36 additional elements.
First extra element 134:
7.905850232699706

So here is what I did to add the entry for year 2050 in the existing dataset
#New year vallue
a = 2050
#Find corresponding y value using the intercept and slope for the best line calculated earlier
b= intercept + slopea
#Append these values to the existing dataset
df= df.append({‘Year’:2050,‘CSIRO Adjusted Sea Level’: b}, ignore_index=True)
x=df[‘Year’]
#Find the slope and intercept passing through the year 2050
slope, intercept, r_value, p_value, std_err = linregress(x,y)
plt.plot(x, intercept + slope
x, ‘r’, label=‘fitted line’)
plt.xlabel(‘Year’)
plt.ylabel(‘Sea Level (inches)’)
plt.title(‘Rise in Sea Level’)

I am not sure what I am doing wrong and why the test modules have extra intercept values.

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36`.

Challenge: Sea Level Predictor

I’m going to try to help you without explicitly telling you what to do.

Linear regression tells you the line of best fit for the data you know.

Plotting a line is easy if you know it’s slope.

You don’t always need to rely on your dataframe for axis data when making a plot.

The test is not wrong.

I guess thats what I have done here. I found the slope and intercept from the known data from the original dataframe then by using the this slope and intercept I found the value for year 2050. My concern is althought the intercept value for 2050 is somewhat similar. I seem to be missing the intercept values from between. The last year in the given dataframe is 2013. Do we need to find values for all the years between 2013-2050? My last intercept value is 7.842805648687559 what about these values as expected by test?
7.905850232699706,

• 7.968894816711838,
• 8.03193940072397,
• 8.094983984736103,
• 8.158028568748236,
• 8.221073152760368,
• 8.284117736772515,
• 8.347162320784648,
• 8.41020690479678,
• 8.473251488808913,
• 8.536296072821045,
• 8.599340656833178,
• 8.66238524084531,
• 8.725429824857457,
• 8.78847440886959,
• 8.851518992881722,
• 8.914563576893855,
• 8.977608160905987,
• 9.040652744918134,
• 9.103697328930252,
• 9.166741912942399,
• 9.229786496954517,
• 9.292831080966664,
• 9.35587566497881,
• 9.41892024899093,
• 9.481964833003076,
• 9.545009417015194,
• 9.608054001027341,
• 9.671098585039488,
• 9.734143169051606,
• 9.797187753063753,
• 9.860232337075871,
• 9.923276921088018,
• 9.986321505100136,
• 10.049366089112283,
• 10.11241067312443]

@ yorgyetson: Few more clues can really help me out here.

You are finding the sea level value for year 2050 and years in-between from the calculated slope and intercept of the best fit line. In calculations, based on these parameters, both slope and intercept shouldn’t change (otherwise it wouldn’t be linear equation), what changes is the `x` (year) and the resulting sea level. Tests don’t check slope or intercept directly.

Thank you this helped much. Thats what I wanted to know. Basically I was just trying to plot line for 2050 and skipped all the years in between. Mat be I got the problem statement wrong. Plotting the data between 2014 to 2050 solved it for me.

A post was split to a new topic: Sea Level Test Case Question