2015年2月5日 星期四

[機器學習] Prediction with Expert Advice - exp strategy

Prediction with Expert Advice, PWEA 又稱 repeated game ( 預測者 v.s. 外部環境)

此 PWEA 運作過程如下:
假設有 $N$ 個專家(expert);對 預測回合  $t := 1,2,...T$,
STEP1:環境會產生 1. 專家建議 $\{f_{i,t}\}_{i=1}^N$ 與 2. 真實輸出 $y_t$ (我們想要預測此值,但目前未知)
STEP2 :我們 獲得 前述 由環境產生的 該回合 專家建議
STEP3:我們由專家建議 建構 該回合的 預測函數 $\hat p_t$
STEP4:一旦完成 $\hat p_t$,我們可獲得真實輸出 $y_t$,此時 可計算 loss $l(\hat p_t, y_t)$ 且 對每一個 (第 $i$ 個) 專家 而言,可計算其對應 loss $l(f_{i,t},y_t)$

目標:使 cumulative regret 最小
\[{R_T}: = \sum\limits_{t = 1}^T l ({{\hat p}_t},{y_t}) - \underbrace {\mathop {\min }\limits_{i = 1,...,N} \sum\limits_{t = 1}^T l ({f_{i,t}} - {y_t})}_{{\rm{Best\;\;expert\;\;in\;\;hindersight}}}\]最好的情況是 $R(T) = o(T) $ 亦即 當 $T \to \infty$,$R_T/T \to 0$

General PWEA Strategy
對每一個專家 $i$ ,透過 給定適當的權重 weight $w_{i,t}$ 來反映我們對此專家的信心。最常見的方法為使用 Weighted Average or Weighted majority。
\[{\hat p_t}: = \frac{{\sum\limits_{i = 1}^N {{w_{i,t}}{f_{i,t}}} }}{{\sum\limits_{i = 1}^N {{w_{i,t}}} }}
\]
那麼權重該如何計算?
對時刻 $t+1$ 而言,我們定義 $\eta := \ln q$ 則
\[\begin{array}{l}
{w_{i,t + 1}} = {w_{i,t}}{\left( {\frac{1}{q}} \right)^{{l_{i,t}}}} = {w_{i,t}}{\left( {\frac{1}{q}} \right)^{l\left( {{f_{i,t}},{y_t}} \right)}}\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = {w_{i,t}}{\left( {{e^{ - \eta }}} \right)^{l\left( {{f_{i,t}},{y_t}} \right)}}
\end{array}\]

Comment
注意到
\[\begin{array}{l}
{w_{i,t + 1}} = {w_{i,t}}{\left( {{e^{ - \eta }}} \right)^{l\left( {{f_{i,t}},{y_t}} \right)}}\\
 \Rightarrow \left\{ \begin{array}{l}
{w_{i,2}} = {w_{i,1}}{\left( {{e^{ - \eta }}} \right)^{l\left( {{f_{i,1}},{y_1}} \right)}}\\
{w_{i,3}} = {w_{i,2}}{\left( {{e^{ - \eta }}} \right)^{l\left( {{f_{i,2}},{y_2}} \right)}} = {w_{i,1}}{\left( {{e^{ - \eta }}} \right)^{l\left( {{f_{i,1}},{y_1}} \right) + l\left( {{f_{i,2}},{y_2}} \right)}}\\
\begin{array}{*{20}{c}}
{}
\end{array} \vdots
\end{array} \right.
\end{array}\]故我們有
\[{w_{i,t}} = {w_{i,1}}{\left( {{e^{ - \eta }}} \right)^{\sum\limits_{s = 1}^{t - 1} {l\left( {{f_{i,s}},{y_s}} \right)} }}\]
且我們可進一步定義在時刻 $t$ 的總權重
\[
W_t := \sum_{i=1}^N w_{i,t}
\]

==================
Theorem: 假設 loss $l$ 為取值為 $[0,1]$ 的 convex 函數,且 $w_{i,1} :=1$  則 exponentially strategy 保證 cumulative regret
\[
R_T \le \frac{\ln N}{\eta} + \frac{\eta T}{8}
\]==================

Proof:
首先觀察 $\ln W_{T+1}/W_1$ 的下界
\[\begin{array}{l}
\ln \left( {\frac{{{W_{T + 1}}}}{{{W_1}}}} \right) = \ln \left( {\frac{{\sum\limits_{i = 1}^N {{w_{i,T + 1}}} }}{{\sum\limits_{i = 1}^N {{w_{i,1}}} }}} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = \ln \left( {\frac{{\sum\limits_{i = 1}^N {{w_{i,T + 1}}} }}{N}} \right) = \ln \left( {\sum\limits_{i = 1}^N {{w_{i,T + 1}}} } \right) - \ln \left( N \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} \ge \ln \left( {\mathop {\max }\limits_{1 \le i \le N} {w_{i,T + 1}}} \right) - \ln \left( N \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = \ln \left( {\mathop {\max }\limits_{1 \le i \le N} {w_{i,1}}{{\left( {{e^{ - \eta }}} \right)}^{\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} }}} \right) - \ln \left( N \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = \ln \left( {\mathop {\max }\limits_{1 \le i \le N} 1 \cdot {{\left( {{e^{ - \eta }}} \right)}^{\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} }}} \right) - \ln \left( N \right)\begin{array}{*{20}{c}}
{}&{}&{}
\end{array}\left( {{w_{i,1}} = 1} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = \mathop {\max }\limits_{1 \le i \le N} \ln \left( {{e^{ - \eta \sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} }}} \right) - \ln \left( N \right)\begin{array}{*{20}{c}}
{}&{}&{}
\end{array}\left( {{\rm{monotoncity}}\begin{array}{*{20}{c}}
{}
\end{array}{\rm{of}}\begin{array}{*{20}{c}}
{}
\end{array}{\rm{log}}} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = \mathop {\max }\limits_{1 \le i \le N} \left( { - \eta \sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} } \right) - \ln \left( N \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} =  - \eta \mathop {\min }\limits_{1 \le i \le N} \left( {\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} } \right) - \ln \left( N \right)\begin{array}{*{20}{c}}
{}&{}&{}
\end{array}\left( {{\rm{max}} - f =  - \min f} \right) \ \ \ \ \ \ \ \ (*)
\end{array}\]接著我們推導  $\ln W_{T+1}/W_1$ 的上界如下:首先觀察
\[\ln \left( {\frac{{{W_{T + 1}}}}{{{W_T}}}} \right) = \ln \left( {\frac{{{W_{T + 1}}}}{{{W_T}}}\frac{{{W_T}}}{{{W_{T - 1}}}}...\frac{{{W_3}}}{{{W_2}}}\frac{{{W_2}}}{{{W_1}}}} \right) = \sum\limits_{t = 1}^T {\ln \left( {\frac{{{W_{t + 1}}}}{{{W_t}}}} \right)} \]故
\[\begin{array}{l}
\ln \left( {\frac{{{W_{t + 1}}}}{{{W_t}}}} \right) = \ln \left( {\frac{{\sum\limits_{i = 1}^N {{w_{i,t + 1}}} }}{{{W_t}}}} \right) = \ln \left( {\frac{{\sum\limits_{i = 1}^N {{w_{i,t}}{e^{ - \eta l\left( {{f_{i,t}},{y_t}} \right)}}} }}{{{W_t}}}} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} = \ln \left( {E\left[ {{e^{ - \eta l\left( {{f_{I,t}},{y_t}} \right)}}} \right]} \right)\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array}\left( {P\left( {I = i} \right): = \frac{{{w_{i,t}}}}{{{W_t}}}} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} \le \eta E\left[ { - l\left( {{f_{I,t}},{y_t}} \right)} \right] + \frac{{{\eta ^2}{{\left( {1 - 0} \right)}^2}}}{8}\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array}\left( {{\rm{Hoeffding's}}\begin{array}{*{20}{c}}
{}
\end{array}{\rm{inequality}}} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} =  - \eta E\left[ {l\left( {{f_{I,t}},{y_t}} \right)} \right] + \frac{{{\eta ^2}}}{8}\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} \le  - \eta l\left( {E\left[ {{f_{I,t}}} \right],{y_t}} \right) + \frac{{{\eta ^2}}}{8}\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array}\left( {{\rm{Jensen's}}\begin{array}{*{20}{c}}
{}
\end{array}{\rm{inequality}}} \right)\\
\begin{array}{*{20}{c}}
{}&{}&{}
\end{array} =  - \eta l\left( {{{\hat p}_t},{y_t}} \right) + \frac{{{\eta ^2}}}{8}\begin{array}{*{20}{c}}
{}&{}&{}&{}
\end{array}
\end{array}\]上式最後一個等號成立因為:
\[{{\hat p}_t}: = \frac{{\sum\limits_{i = 1}^N {{w_{i,t}}{f_{i,t}}} }}{{\sum\limits_{i = 1}^N {{w_{i,t}}} }} = \frac{{\sum\limits_{i = 1}^N {{w_{i,t}}{f_{i,t}}} }}{{{W_t}}} = \sum\limits_{i = 1}^N {\underbrace {\frac{{{w_{i,t}}}}{{{W_t}}}}_{ = P\left( {I = i} \right)}} {f_{i,t}} = E\left[ {{f_{I,t}}} \right]\]故我們有
\[\ln \left( {\frac{{{W_{T + 1}}}}{{{W_1}}}} \right) \le \sum\limits_{t = 1}^T {\left( { - \eta l\left( {{{\hat p}_t},{y_t}} \right) + \frac{{{\eta ^2}}}{8}} \right)} \ \ \ \ \ \ \ (\star)
\]現在總結 $(*)$ 與 $(\star)$ 可推知
\[\begin{array}{l}
 - \eta \mathop {\min }\limits_{1 \le i \le N} \left( {\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} } \right) - \ln \left( N \right) \le \ln \left( {\frac{{{W_{T + 1}}}}{{{W_1}}}} \right) \le \sum\limits_{t = 1}^T {\left( { - \eta l\left( {{{\hat p}_t},{y_t}} \right) + \frac{{{\eta ^2}}}{8}} \right)} \\
 \Rightarrow  - \eta \mathop {\min }\limits_{1 \le i \le N} \left( {\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} } \right) - \ln \left( N \right) \le  - \eta \sum\limits_{t = 1}^T {l\left( {{{\hat p}_t},{y_t}} \right) + \frac{{{\eta ^2}}}{8}T} \\
 \Rightarrow \eta \sum\limits_{t = 1}^T {l\left( {{{\hat p}_t},{y_t}} \right)}  - \eta \mathop {\min }\limits_{1 \le i \le N} \left( {\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} } \right) \le \frac{{{\eta ^2}}}{8}T + \ln \left( N \right)\\
 \Rightarrow \underbrace {\sum\limits_{t = 1}^T {l\left( {{{\hat p}_t},{y_t}} \right)}  - \mathop {\min }\limits_{1 \le i \le N} \left( {\sum\limits_{s = 1}^T {l\left( {{f_{i,s}},{y_s}} \right)} } \right)}_{ = {R_T}} \le \frac{\eta }{8}T + \frac{{\ln \left( N \right)}}{\eta } \ \ \ \ \square
\end{array}\]另外我們亦可求解最佳 $\eta$ 滿足 如下:
\[\begin{array}{l}
\frac{d}{{d\eta }}\left( {\frac{\eta }{8}T + \frac{{\ln \left( N \right)}}{\eta }} \right) = 0\\
 \Rightarrow {\eta ^*} = \sqrt {\frac{{8\ln \left( N \right)}}{T}}
\end{array}\]