Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Influence Function 線形回帰での例

L(z,θ)=(y−x⊤θ)2∇θL(z,θ)=−2(y−x⊤θ)x=−2xy+2(x⊤θ)xR(θ)=(y−Xθ)⊤(y−Xθ)∇θR(θ)=−2X⊤y+2(X⊤X)θH=∇θ2R(θ)=2(X⊤X)θ^=(X⊤X)−1X⊤y\begin{align} L(z, \theta) &= (y - x^\top \theta)^2\\ \nabla_{\theta} L(z, \theta) &= - 2 (y - x^\top \theta) x = -2xy + 2 (x^\top \theta) x\\ R(\theta) &= (y - X\theta)^\top (y - X\theta) \\ \nabla_{\theta} R(\theta) &= -2 X^\top y + 2 (X^\top X) \theta \\ H = \nabla_{\theta}^2 R(\theta) &= 2 (X^\top X)\\ \hat{\theta} &= (X^\top X)^{-1} X^\top y \end{align}

なので

Iup,params(z)=−Hθ^−1∇θL(z,θ^)=−(2X⊤X)−1(−2(y−x⊤θ^)x)Iup,loss(z,ztest)=−∇θL(ztest,θ^)⊤Hθ^−1∇θL(z,θ^)=(2(ytest−xtest⊤θ^)xtest)⊤(2X⊤X)−1(−2(y−x⊤θ^)x)\begin{align} \mathcal{I}_{up, params}(z) &= -H^{-1}_{\hat{\theta}} \nabla_{\theta} L(z, \hat{\theta})\\ &= -( 2 X^\top X )^{-1} ( - 2 (y - x^\top \hat\theta) x ) \\ \mathcal{I}_{up, loss}(z, z_{test}) &= - \nabla_{\theta} L(z_{test}, \hat{\theta})^\top H^{-1}_{\hat{\theta}} \nabla_{\theta} L(z, \hat{\theta}) \\ &= (2 (y_{test} - x_{test}^\top \hat\theta) x_{test} )^\top ( 2X^\top X )^{-1} ( - 2 (y - x^\top \hat\theta) x ) \end{align}
[0.3 0.7]
array([0.27816619, 0.71295385])

Influence (params)

LOO

θ^−z−θ^\hat{\theta}_{-z} - \hat{\theta}
array([[0.43758721, 0.891773 ], [0.0202184 , 0.83261985], [0.7936977 , 0.22392469], [0.65632959, 0.13818295], [0.0641475 , 0.69247212]])

Influence Function

−1nIup,params-\frac{1}{n}\mathcal{I}_{up, params}
array([[0.43758721, 0.891773 ], [0.0202184 , 0.83261985], [0.7936977 , 0.22392469], [0.65632959, 0.13818295], [0.0641475 , 0.69247212]])
<Figure size 400x400 with 1 Axes>

Influence (loss)

array([[0.07103606, 0.0871293 ]])
array([0.00720099])

LOO

L(ztest,θ^−z)−L(ztest,θ^)L(z_{test}, \hat{\theta}_{-z}) - L(z_{test}, \hat{\theta})
array([[0.43758721, 0.891773 ], [0.72525428, 0.50132438], [0.97861834, 0.79915856], [0.5759465 , 0.9292962 ], [0.34535168, 0.92808129]])

Influence Function

−1nIup,loss-\frac{1}{n}\mathcal{I}_{up, loss}
array([[0.43758721, 0.891773 ], [0.72525428, 0.50132438], [0.97861834, 0.79915856], [0.5759465 , 0.9292962 ], [0.34535168, 0.92808129]])
<Figure size 400x400 with 1 Axes>