愉快的学习就从翻译开始吧_Multi-step Time Series Forecasting_11_Multi-Step LSTM Network_Invert Transforms

Invert Transforms/翻转变换

After the forecasts have been made, we need to invert the transforms to return the values back into the original scale.

预测完成后,我们需要反转变换以将值返回到原始比例。

This is needed so that we can calculate error scores and plots that are comparable with other models, like the persistence forecast above.

这是需要的,以便我们可以计算与其他模型相比的误差分数和图表,如上面的持续预测。

We can invert the scale of the forecasts directly using the MinMaxScaler object that offers an inverse_transform() function.

我们可以使用MinMaxScaler对象提供的inverse_transform()函数直接反转预测的比例。

We can invert the differencing by adding the value of the last observation (prior months’ shampoo sales) to the first forecasted value, then propagating the value down the forecast.

我们可以通过将最后一次观察值(上个月的洗发水销售量)添加到第一个预测值中,然后将该值向下传播到预测值来反转差异。

(如果是向后传播应该是第一个观察值加上第一个预测值(差分的),如果是向前传播,应该是最后一个观察值减去最后一个预测值,真不明个作者怎么会把最后一个观察值加第一个预测值?)

This is a little fiddly; we can wrap up the behavior in a function name inverse_difference() that takes the last observed value prior to the forecast and the forecast as arguments and returns the inverted forecast.

这有点烦; 我们可以将这些行为包含在名称inverse_difference()函数内,该函数将预测和预测之前的最后一个观测值作为参数,并返回反转的预测(这个表达是正确的,那么上句话就是错的)。

Putting this together, we can create an inverse_transform() function that works through each forecast, first inverting the scale and then inverting the differences, returning forecasts to their original scale.

综合起来,我们可以创建一个inverse_transform()函数,它可以在每个预测中起作用,首先反转比例,然后反转差分,将预测返回到原始比例尺。

We can call this function with the forecasts as follows:

我们可以使用forecasts来调用此函数如下:

We can also invert the transforms on the output part test dataset so that we can correctly calculate the RMSE scores, as follows:

我们也可以反转输出部分测试数据集上的变换,以便我们可以正确计算RMSE得分,如下所示:

We can also simplify the calculation of RMSE scores to expect the test data to only contain the output values, as follows:

我们还可以简化RMSE分数的计算,以期望测试数据仅包含输出值,如下所示:

猜你喜欢

转载自blog.csdn.net/dreamscape9999/article/details/80735337
今日推荐