LoginSignup
2
0

More than 3 years have passed since last update.

PRML (1.90) の導出について

Last updated at Posted at 2020-06-06

はじめに

本記事は, 機械学習の教科書の決定版ともいえる, Christopher Bishop先生による『Pattern Recognition and Machine Learning (パターン認識と機械学習)』, 通称PRMLを, 私の所属する生物測定学研究室の輪読会で扱っていたときに出た質問に解答したものです. なお, 他の演習問題の解答例に関する記事については, PRML 演習問題 解答集 まとめをご覧ください.

導入

まず、PRML (1.90) 式の直前の式にあるように、二乗誤差に、$\mathbb { E } [ t | \mathbf { x } ]$ を導入する形で、以下のように変形を行います。

\begin{align*} 
\left \{  y ( \mathbf { x } ) - t \right \} ^ { 2 } & = \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] + \mathbb { E } [ t | \mathbf { x } ] - t \right \} ^ { 2 } \\ 
& = \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } + 2 \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} + \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} ^ { 2 } 
\end{align*}

これを、以下の (1.87) 式の期待損失

\begin{align*} 
\mathbb { E } [ L ] = \iint \left \{  y ( \mathbf { x } ) - t \right \} ^ { 2 } p \left ( \mathbf { x } , t \right ) \mathrm { d } \mathbf { x } \mathrm { d } t
\tag {1.87}
\end{align*}

に代入すると、以下のように、3項からなる形で期待損失を変形できますね。

\begin{align*} 
\mathbb { E } [ L ] &= \iint \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } p \left ( \mathbf { x } , t \right ) \mathrm { d } \mathbf { x } \mathrm { d } t \\
& + 2 \iint \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} p \left ( \mathbf { x } , t \right ) \mathrm { d } \mathbf { x } \mathrm { d } t \\
& + \iint \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} ^ { 2 } p \left ( \mathbf { x } , t \right )  \mathrm { d } \mathbf { x } \mathrm { d } t 
\end{align*}

各項の計算

この式のそれぞれの項に注目して、よりシンプルな形に変形していきましょう。

第1項

まず第1項は、$p \left ( \mathbf { x } , t \right ) = p \left ( t | \mathbf { x } \right ) p \left ( \mathbf { x } \right )$ を利用し、かつ $t$ に関する積分だけ括り出せば、

\begin{align*} 
\iint \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } p \left ( \mathbf { x } , t \right ) \mathrm { d } \mathbf { x } \mathrm { d } t  & = 
\iint \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } p \left ( t | \mathbf { x } \right ) p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x } \mathrm { d } t \\
& = \left ( \int \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x } \right ) \cdot \left ( \int p \left ( t | \mathbf { x } \right )  \mathrm { d } t \right ) \\
& = \int \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x } 
\end{align*}

という変形を行えます。

第2項

次に、クロス項である第2項は、先に $t$ に関する積分を行う形で括り出せば、

\begin{align*} 
\iint \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} p \left ( \mathbf { x } , t \right ) \mathrm { d } \mathbf { x } \mathrm { d } t & = 
\int \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} \left [ \int \left \{ \mathbb { E } [ t | \mathbf { x } ] - t \right \} p \left ( t | \mathbf { x } \right ) \mathrm { d } t \right ] p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x }  \\
& = \int \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ]  \right \} \left [  \mathbb { E } [ t | \mathbf { x } ] \int p \left ( t | \mathbf { x } \right ) \mathrm { d } t - \int t p \left ( t | \mathbf { x } \right ) \mathrm { d } t \right ] p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x }  \\
& = \int \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ]  \right \} \left [  \mathbb { E } [ t | \mathbf { x } ]  - \mathbb { E } [ t | \mathbf { x } ] \right ] p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x }  \\
& = 0
\end{align*}

のように変形でき、クロス項が $0$ となり、消えることがわかります。なおここで、条件付き分布の和が1 ( $\int p \left ( t | \mathbf { x } \right ) \mathrm { d } t = 1$ ) であること、および条件付き期待値の定義 $\mathbb { E } [ t | \mathbf { x } ] = \int t p \left ( t | \mathbf { x } \right ) \mathrm { d } t$ を用いました。

第3項

最後に、第3項に関しては、やはり $t$ に関する積分を先に行う形で括り出せば、

\begin{align*} 
\iint \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} ^ { 2 } p \left ( \mathbf { x } , t \right )  \mathrm { d } \mathbf { x } \mathrm { d } t & = 
\iint \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} ^ { 2 } p \left ( t | \mathbf { x } \right ) p \left ( \mathbf { x } \right )  \mathrm { d } \mathbf { x } \mathrm { d } t \\
& = \int \left ( \int \left \{  \mathbb { E } [ t | \mathbf { x } ] - t \right \} ^ { 2 } p \left ( t | \mathbf { x } \right ) \mathrm { d } t \right ) p \left ( \mathbf { x } \right )  \mathrm { d } \mathbf { x } \\
& = \int \operatorname { var } \left [ t | \mathbf { x } \right ] p \left ( \mathbf { x } \right )  \mathrm { d } \mathbf { x }
\end{align*}

と変形することができます。
ここで、条件付き分散を $\operatorname { var } \left [ t | \mathbf { x } \right ] = \int \left ( \mathbb { E } [ t | \mathbf { x } ] - t \right ) ^ { 2 } p \left ( t | \mathbf { x } \right ) \mathrm { d } t$ のように定義しました。
なお、これは、分散に関する定義式

\begin{align*}
\operatorname { var } [ f ] = \mathbb { E } \left[ \left ( f ( x ) - \mathbb { E } \left [ f ( x ) \right ] \right ) ^ { 2 } \right] \tag { 1.38 }
\end{align*}

の期待値を(内側、外側共に)条件付き分布による期待値に差し替えてやると考えれば良いと思います。

結論

さて、このように第1項から第3項までがそれぞれ計算できたので、これを足し合わせる形で (1.90) 式が導出できます。

\begin{align*} 
\mathbb { E } [ L ] = \int \left \{  y ( \mathbf { x } ) - \mathbb { E } [ t | \mathbf { x } ] \right \} ^ { 2 } p \left ( \mathbf { x } \right ) \mathrm { d } \mathbf { x } + \int \operatorname { var } \left [ t | \mathbf { x } \right ] p \left ( \mathbf { x } \right )  \mathrm { d } \mathbf { x } 
\tag { 1.90 }
\end{align*}

なお、古い英語版のPRMLでは、(1.90) の第2項が誤っていますが、これは errata Version 1 にて指摘されており、日本語版では正しく修正されています。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0