【问题标题】:Calculation of lower and upper confidence interval with GluonTs用 GluonT 计算上下置信区间
【发布时间】:2021-05-15 01:31:41
【问题描述】:

我正在使用 GluonT 进行月度预测,需要计算置信区间的上限和下限。 GluonTs 有 plot() 函数,它使我们能够使用预测类来绘制它,但我想使用我自己的 plot 函数,它需要置信区间。

  1. 使用 GluonTs Forecast 类为我们提供了一个置信区间,但它是一个单一的值。 我们如何使用它来获得 yhat_upper 和 yhat_lower ?

    np.percentile(forecasts_multivariate[0].samples.sum(axis = 1), 90)

  2. 使用基本 t 检验。但这没有给出正确的结果!。它返回上置信区间和下置信区间

    将 scipy.stats 导入为 st

    st.t.interval(alpha=0.95, df=len(pred) - 1, loc=np.mean(pred), scale=st.sem(pred))

我们如何使用 GluonT 获得上限和下限 CI?

【问题讨论】:

    标签: python-3.x time-series prediction forecasting confidence-interval


    【解决方案1】:
    import pandas as pd
    df_bands = pd.DataFrame(forecasts[0].samples, columns = list(df_final.index[-7:].values), dtype = float)
    lower_band_90 = df_bands.quantile(q=0.05, axis=0)
    upper_band_90 = df_bands.quantile(q=0.95, axis=0)
        
    lower_band_50 = df_bands.quantile(q=0.25, axis=0)
    upper_band_50 = df_bands.quantile(q=0.75, axis=0)
    

    【讨论】:

      猜你喜欢
      • 2020-05-08
      • 2015-08-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-23
      • 2021-01-24
      • 2022-01-22
      • 2017-11-05
      • 1970-01-01
      相关资源
      最近更新 更多