• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
ying_vincent
博客园    首页    新随笔    联系   管理    订阅  订阅

Machine Learning No.2: Linear Regression with Multiple Variables

1. notation:

n = number of features

x(i) = input (features) of ith training example

 = value of feature j in ith training example

2. Hypothesis:

3. Cost function:

4. Gradient descent:

Repeat {

  

}

substituting cost function, then

Repeat {

  

  (simultaneously update θj for j = 0, ... n)

}

5. Mean normalization

replace xi with xi - µi to make features have approximately zero mean(Do not apply to x0 = 1).

ex: x_1 = (x_1 - u_1) / s_1

6. Declare convergence if J(θ) decreases by less than 10^-3 in one iteration.

if α is too small: slow convergence.

if α is too large: J(θ) may not decrease on every iteration; may not converge

7. normal equation

Octave: pinv(X'*X)*X'*y

8. comparation between gradient descent and normal equation

Gradient Descent: need to choose α

                            needs many iterations

          works well even when n is large

Normal Equation: No need to choose α

           Don't need to iterate

         need to compute pinv(X'X)

         slow if n is very large

9. Some problems

  what if X'T is non-invertible?

    Redundant features(linearly dependent)

           E.g.  x1 = size in feet^2

                   x2 = size in m^2

    Too many features(e.g. m <= n)

         Delete some features, or use regularization

posted @ 2013-06-25 08:55  ying_vincent  阅读(222)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3