C4W1 Assignment1 diff moving average outputing wrong numbers?

when I tried to do the diff moving avg,
This is my diff_moving_avg line:

diff_moving_avg1 = moving_average_forecast(diff_series, window_size=50)
the difference moving average for whole SERIES has shape=(1411,)
but when i sliced it

the graph is off and clearly the results are wrong. I have been stuck on this for many days. help

hi @fengcainiao

can I know why do you feel the graph is off?

can you share screenshot of your results in comparison to the instructions mentioned in the assignment!!!

Regards
DP

This is the expected output suggested by the assignment. In addition, this is a moving average calculation. However, the forecast’s y axis(value) is way off the value of the original data. This means there is something wrong with the diff_moving_avg1 function.

so did you play around with the values to see if gives a different result? you have used window size of 50, do you feel as general rule of thumb you are using the correct value?..

I am sharing post comment which explains a bit of same, it will probably help you make changes and try again

Regards
DP

Yes, the strange part that i dont understand is that by making the window size bigger (i.e.=500) the DMA should smoothout across the graph. But when I tried that the DMA forecast does not change. Did I plot the wrong function? Or did the program somehow stored the wrong value?


Thank you so much for your help

Also another one that might be problematic is that my np_forecast was prompted to have the wrong shape. Shouldn’t the forecase of the entire series have 14XX as the shape as it contains 14XX numbers? How come the unitest algo suggests that it should only contain 25 data points?

The MA forecast graph was the same as the expected output by the way.

Perhaps the unit test uses an entirely different data set.

The test you failed is because you are suppose to specified series, i.e. 25 but you have 1141, make that correction. @fengcainiao

How do i do that? is there any documentation to how to specified a series with the numpyarray.

Also i still dont understand the slicing problem with the different_moving average.
![image|690x281]posting codes is against community guidelines

please don’t post codes here.

Kindly send me codes by personal DM.

click on my name and then message.

As par what I saw here, you are using a global variable for WINDOW_SIZE, where as the call argument for moving average forecast is recalled for the particular grade cell as window_size

hi @fengcainiao

go through below thread comment where it will help you debug your codes.

let me know if you are still stuck!

regards
DP

Hello Deepti,
I have DM you some of the code. I am not sure if its my code that is problematic or if the grading utility is not working.

Can you please help me?
Thanks,
PF

please go through my previous linked comment shared here where the learner has similar issue s yours and there were multiple code errors, so go through that post and compare your codes as one of the error is similar as shared by that learner especially the moving_average_forecast.

There were more errors by that learners, so you can cross verify those errors with your codes.

let me know if grader is fails still after making those correction.

The grader is working perfectly fine, there is error in your codes for moving average forecast.

hi @fengcainiao

to get a fresh latest copy of assignment.

Click File ==>Open

select all file except the assignment file and then delete.

Next select the assignment file and rename it, so the updated version gets download.

If you do not want to save the old copy, you can delete the assignment file too. In case you deleted the assignment file too, you get a 404 error in your screen.

if you don’t delete and rename the file, you do not get 404 error.

At this time, click :question:on the right top corner, and then click reboot.

Once rebooting is done, click :question: again, now click Get the latest Version and then Update Lab.

You have the latest copy of assignment to workup on.

Regards
DP

@fengcainiao

did you go through this post

and compare your codes?

you are doing same mistake the learner has done in linked post here.

you are only checking the data split codes, but your error could be related to other codes cell, so go through the linked post points one by one, and compare your codes.

@fengcainiao

check the below point

for diff_moving_avg where you perform correct slicing, that is again incorrect, taking len of series_valid will not get you diff moving avg.
it should be [SPLIT_TIME-365-WINDOW_SIZE:]

you were before doing the same mistake but later correction still required correction as you used value 50 instead of using WINDOW_SIZE:

Please also make sure to use it capitals only.

you have shared your codes for naive forecast, so I cannot confirm on that.

Your compute metrics codes are also incorrect, you hard coded the path which again can cause autograde failure.

don’t recall the metrics value separately as errors And then use in calculating the mse and mae, directly use it in the calculation the mse and mae.
Another mistake, you are using incorrect function recall to calculate mse and mae.

It should be tf.keras.losses.MSE(args metrics assigned for that grade cell).numpy( )

Same for mae calculation.

Regards
DP