zoukankan      html  css  js  c++  java
  • 01 Linear Regression with One Variable

    Symbols:

    • m = Number of training examples
    • x’s = “input” variable /features
    • y’s = “output” variable / “target” variaable
    • (x, y) = one training example
    • ((x^{(i)}, y^{(i)})) = (i_{th}) training example
    • h(x) = hypothesis function
    • (h_ heta(x) = heta_0 + heta_1x) shorthand:h(x)

    Cost Function

    • squared cost function
      [J( heta_0, heta_1) = dfrac {1}{2m} displaystyle sum _{i=1}^m left ( hat{y}_{i}- y_{i} ight)^2 = dfrac {1}{2m} displaystyle sum _{i=1}^m left (h_ heta (x_{i}) - y_{i} ight)^2]
    • Goal: (minimize_{ heta_0, heta_1}J( heta_0, heta_1))

    Gradient descent

    repeat until convergence {

    ( heta_j := heta_j - alpha frac{partial}{partial heta_j} J( heta_0, heta_1)) (for j = 0 and j = 0)
    }

    需要同时更新( heta_j), 否则先更新( heta_i)会对后面的项的更新产生影响

    (egin{align*} ext{repeat until convergence: } lbrace & ewline heta_0 := & heta_0 - alpha frac{1}{m} sumlimits_{i=1}^{m}(h_ heta(x_{i}) - y_{i}) ewline heta_1 := & heta_1 - alpha frac{1}{m} sumlimits_{i=1}^{m}left((h_ heta(x_{i}) - y_{i}) x_{i} ight) ewline brace& end{align*})

  • 相关阅读:
    orm添加表记录
    创建多表模型
    包的使用
    日志写法
    os模块,是通过和操作系统交互进行操作
    sys python解释器做交互
    软件开发规范
    模块 time模块 datatime模块 random模块
    装饰器
    装饰器进阶
  • 原文地址:https://www.cnblogs.com/QQ-1615160629/p/01-Linear-Regression-with-One-Variable.html
Copyright © 2011-2022 走看看