mrdbourke / tensorflow-deep-learning

All course materials for the Zero to Mastery Deep Learning with TensorFlow course.
https://dbourke.link/ZTMTFcourse
MIT License
5.05k stars 2.5k forks source link

Notebook 10: Section 309 MASE #585

Open patrickofdenver opened 10 months ago

patrickofdenver commented 10 months ago

Hi friends,

When using the 'mean_absolute_scaled_error' function, I was getting an error about being unable to subtract lists. I had to modify it to turn the y_true and naive_forecast into np.array in order for the error to go away and get the same result as the video. Unsure if it'll throw an error down the road, but I changed the function as follows:

def mean_absolute_scaled_error(y_true, y_pred): """ Implement MASE (assuming no seasonality of data). """ mae = tf.reduce_mean(tf.abs(np.array(y_true) - np.array(y_pred)))

Find MAE of naive forecast (no seasonality)

mae_naive_no_season = tf.reduce_mean(tf.abs(np.array(y_true[1:]) - np.array(y_true[:-1]))) # our seasonality is 1 day (hence the shifting of 1 day)

return mae / mae_naive_no_season