Hi, I have a problem with the latest project of the data analysis curriculum.
I passed the other tests but the forecasts on the second line, the one from 2000 to 2050 are different from those of the test.
I don’t understand where the mistake is.
This is my repo WindyUnpleasantScan - Replit
The line looks basically ok just by eyeball, but where did the first line go?
oh sorry. look at it now. i have only a failures. the code is complete.
I understood the mistake which could be that it’s on the first fit line if I’m not mistaken. The values look different because mine are rounded while those in the test are not but still it tells me that my predictions are 134 while those in the test are 171 and yet I used np.arange(1880,2051).
I think it’s due to the fact that I use data from 1880 to 2013 but then I predict from 1880 to 2050. In fact, the lines of the csv are 134 while the forecasts I should get would be 171, exactly those until 2050 but I can’t use data that doesn’t exist or from 2013 to 2051.
Can you please share the complete error output and a link to the problem description?
You plot the data twice:
plt.scatter(x=df['Year'],y=df['CSIRO Adjusted Sea Level'])
#here you create a scatter plot of the data points
# Create first line of best fit
linear=stats.linregress(df['Year'],df['CSIRO Adjusted Sea Level'])
lista=[1850.0,1875.0,1900.0,1925.0,1950.0,1975.0,2000.0,2025.0,2050.0,2075.0]
# Here you create a plot of the data again,
plt.plot(df['Year'],df['CSIRO Adjusted Sea Level'])
# but you only need to plot the line.
You do it again in the second line. You don’t need to plot the data again, just the new line.
Other than that, nice work!
1 Like
I removed that line plt.plot but now it always gives me the same error. Only it’s different.Thanks you! The error now is on the second line fit
You did it twice. Check your new line for another plot.
1 Like
Ok now it works. thank you very much I didn’t understand that it was always the same graph on which to plot the two lines of fit.
2 Likes