1. 程式人生 > 其它 >峰值預測效能指標PPTS(Peak percentage of threshold statistic)

峰值預測效能指標PPTS(Peak percentage of threshold statistic)

技術標籤:機器學習

對峰值預測效能的評價指標

一、指標解釋

我在研究論文的時候觀察到了一個性能指標,叫做PPTS(Peak percentage of threshold statistic),翻譯過來是:閾值統計的峰值百分比。這篇論文中給出的定義為:
computes the average absolute relative error of predictands of the top γ% streamflow data.The lower the PPTS,the better the capability to forecast peak flow. Note that the recorded streamflow values are arranged in descending order to compute the PPTS and that the threshold level γ denotes the percentage of data selected from the beginning of the arranged data sequence. The parameter G is the number of values above the threshold level γ.


計算公式為:
可以看到,這個公式與平均相對誤差非常相似
可以從公式看到,這個PPTS其實就是 一個 平均絕對百分比誤差(Mean Absolute Percentage Error,MAPE),但是是將原來的流量序列進行一個降序排列,選擇top γ%的資料進行MAPE的計算。

二、計算設計

我利用這個概念自己設計了一個PPTS的計算

  1. 得到y_true(原始流量)的最大值y_max,與最小值y_min。
  2. 設定delta=y_max-y_min。
  3. 設定一個百分比γ,設閾值為Gamma,Gamma=y_min+p*delta
  4. 利用eff=np.where(y_true>Gamma)得到滿足y_true>Gamma的元素所在的矩陣位置。
  5. 對滿足條件的流量值計算相對誤差的絕對值。
  6. 最後求取平均值即可

三、程式碼如下

// An highlighted block
def PPTS(y_true, y_pred):
    """
    引數:
    y_true -- 測試集目標真實值
    y_pred -- 測試集目標預測值

    返回:
    mape -- MAPE 評價指標
    """
    p=0.01
    y_max=np.max(y_true)
    y_min=np.min(y_true)
    delta=y_max-y_min
    Gamma =
y_min+p*delta mape=0 label= np.where(y_true > Gamma) eff=label[0] l=len(eff) for i,a in enumerate(eff): mape = mape+(np.abs((y_true[a,:] - y_pred[a,:]) / y_true[a,:]) * 100) ppts = mape/ l return ppts

四、小結

自己設計的這個指標與論文中的PPTS還是有一些不同的,它其實是計算了top(1-γ)的MAPE,不過同樣能評估模型對峰值的計算效能了。