Notes on the Elements of Statistical Learning, Ch4, 1

(E of SL) Ch. 4 Notes, 1

Notation

x∈X⊂Rpx \in \mathcal{X}\subset{\mathbb{R}}^p, feature vector, take N samples, we have X={xiT}i=1N\displaystyle X = \{x_i^T\}_{i=1}^N

G={1,...,K}\mathcal{G}= \{1,...,K\}, set of categories, where g(x)∈Gg(x) \in \mathcal{G}. Alternatively, we can also denote the class of xx as yy, where y∈{ek}y \in \{e_k\}, eke_k is the a n-vector with 11 in the kk-th dimension, and 00 elsewhere.

δk(x)\delta_k(x): discriminant function (methods of this kind will classify to the argmax on kk). A linear discriminant function (in xx) will result in a linear decision boundary. The rationale of using argmax comes from categorical distribution (where E(y∣x)=pE(y|x) = p)

Recap

The 0-1 loss

In Ch.2, with a binary loss function [ l(f,y)=1−bool(f=y)\displaystyle l(f,y) = 1 - \mathbf{bool}(f=y), bool\mathbf{bool} is the boolean operator ] , we will have the Bayes classifier. Here we brief review the relationship:

g(x)=k⇔y=ekg(x) = k \Leftrightarrow y=e_k

Then: l(f,y)=yTL⋅fl(f,y) = y^TL\cdot f, where LL is a matrix with 00 on its diagonal and 11 elsewhere, i.e., L=11T−InL = 11^T- I_n

The Bayesian classifier:

min⁡f:x→yR=∫y,xyTLf(x)  dP(x,y)\displaystyle \min_{f:x\rightarrow y}\mathbf{R} = \int_{y,x}y^TLf(x)\;d{\bf P}(x,y)

since ff unconstrained, pointwise minimization, ∀x\displaystyle \forall x:
Rx=∫y∣xyxTL⋅fdP(y∣x)\displaystyle {\bf R_{x}} = \int_{y|x} y_x^TL\cdot fd{\bf P}(y|x)
      =∫y∣xyxTdP(y∣x)⋅L⋅f=E(y∣x)T⋅(11T−In)⋅f⋅\displaystyle \;\;\; = \int_{y|x} y_x^Td{\bf P}(y|x)\cdot{\bf L}\cdot f= \mathbf{E}(y|x)^T \cdot({\bf 11^T - I_n})\cdot f\cdot
      =1−E(y∣x)Tf\displaystyle \;\;\; =1 - \mathbf{E}\big(y|x\big)^Tf, thus we have ∀x\forall x in the support:

f=argmax⁡k(E(yk)∣x)=argmax⁡k(P(yk=1)∣x)f = \text{arg}\max_k\big(\mathbf{E}(y_k)|x\big)=\text{arg}\max_k\big(\mathbf{P}(y_k=1)|x\big)

we will classify class of xx, y^=f(x)\hat{y}=f(x) to the most probable class, or the dominant class in N(x)N(x), NN is some neighborhood.

Logistic Regression

Assumption: with comparison class KK we assume

log⁡P(G=j∣x)P(G=K∣x)=βjTx\log\frac{\mathbf{P}(G=j|x)}{\mathbf{P}(G=K|x)}=\beta_j^T x

⇒\Rightarrow

P(G=j∣x)=exp⁡(βjTx)1+∑iK−1exp⁡(βiTx)\mathbf{P}(G=j|x) = \frac{\exp (\beta_j^T x) }{1+\sum_i^{K-1} \exp(\beta_i^T x)}

we do maximum likelihood:

log⁡L({βi})=∑jlog⁡P(gi∣xi)\log L(\{\beta_i\}) = \sum_j \log \mathbf{P}(g_i | x_i)

Interesting notes

Binary case

if K=2K =2, then the max problem reduce to:

max⁡{βi}log⁡L=∑iNyilog⁡P(yi=1∣xi)+(1−yi)log⁡P(yi=0∣xi)\max_{\{\beta_i\}} \log L = \sum_i^N y_i \log P(y_i=1|x_i) + (1-y_i)\log P(y_i=0|x_i)

max⁡log⁡L=∑j−yjlog⁡(1+∑exp⁡(...))+(1−yj)βTxj+(yj−1)log⁡(1+...)\max \log L = \sum_j - y_j \log(1+\sum\exp(...)) + (1-y_j)\beta^Tx_j + (y_j -1 )\log(1+...)

=∑j(1−yj)βTxj−log⁡(1+...)= \displaystyle \sum_j (1-y_j)\beta^Tx_j - \log(1+...)

∂log⁡L∂β=∑j−yjxj−xjexp⁡(βTxj)1+...=∑jxj(1−pj(1)−yj)\displaystyle\frac{\partial \log L}{\partial \beta} = \sum_j - y_jx_j - x_j\frac {\exp(\beta^T x_j)}{1 + ...} = \sum_j x_j (1 - p_j(1)-y_j)

let pp be the vector of conditional probability being 1 [ P(G=1∣x)\mathbf P(G=1|x) ]

then log⁡L′=XT(1−p−y)\log L' = X^T(1-p-y),

let ∂log⁡L∂ββT=H=−∑jxjxjTexp⁡(βTxj)(1+...)2=XTWX\displaystyle\frac{\partial \log L}{\partial \beta\beta^T} = H = - \sum_j \frac{x_jx_j^T\exp(\beta^Tx_j)}{(1+...)^2} = X^TWX

w.t. W=diag[p1(1−p1),p2(1−p2),...,pN(1−pN)]\displaystyle W=\mathbf{diag}\big [p_1(1-p_1), p_2(1-p_2), ..., p_N(1-p_N)\big ]

[ notice HH is always negative definite ]

multiclass

...