首页 > 其他分享 >Cost function - deeper intuition

Cost function - deeper intuition

时间:2022-10-06 14:12:59浏览次数:55  
标签:function intuition frac sum Cost quad theta where

Cost function - deeper intuition

标签(空格分隔): ML

目录


Given hypothesis \(h\theta=\theta_1+\theta_2x^{(i)}\)

1.cost function where \(\theta_1=0\)

\[J(\theta_1,\theta_2)=J(\theta_2)=\frac{1}{2m}\sum_{i=1}(\theta_2x^{(i)}-y^{(i)})^2\\ =\frac{1}{2m}(\sum_{i=1}(x^{i})^2)\times\theta_2^2-\frac{1}{m}(\sum_{i=1}x^{(i)}y^{(i)}) \times \theta_2 + \frac{1}{2m}(\sum_{i=1}y^{(i)})^2\\ \]

\(\rm{simplified \quad to}\)

\[J(\theta_1,\theta_2)=\lambda_1\times\theta_2^2 +\lambda_2\times \theta_2 + \lambda_3 \\ where \quad \lambda_1=\frac{1}{2m}(\sum_{i=1}(x^{i})^2) \quad, \lambda_2=-\frac{1}{m}(\sum_{i=1}x^{(i)}y^{(i)})\quad,\lambda_3=\frac{1}{2m}(\sum_{i=1}y^{(i)})^2 \]

\(\implies J(\theta_1,\theta_2)\) is a quadratic equation with variable \(\theta_2 \quad where\quad \theta1=0\)

derivative would find the minimum for a quadratic equation.

2.cost function where \(\theta_1 \neq 0\)

2.1 contour plot:(等值线图)

  • explore the relationship between two independent variables and one dependent variable
  • plot two independent variables and one dependent variable(感觉废话!)

used to help identify the combinations that yield benficial outcome values.

2.2 Unfold J(\(\theta_1,\theta_2\)) where \(\theta_1,\theta_2 \neq 0\)

\[J(\theta_1,\theta_2)=\frac{1}{2m}\sum_{i=1}(\theta_1+\theta_2x^{(i)}-y^{(i)})^2 \]

\(\implies J(\theta_1,theta_2)\)definitely are composed of \(\theta_1^2,\theta_2^2\),where derivative cannot work with two independent variables and one dependent variable.

So how to minimize \(J(\theta_1,\theta_2):goal\)?

Solution:contour plot.(example:bow-shaped plot)

标签:function,intuition,frac,sum,Cost,quad,theta,where
From: https://www.cnblogs.com/UQ-44636346/p/16757503.html

相关文章