zoukankan      html  css  js  c++  java
  • Machine learning(2-Linear regression with one variable )

    1、Model representation

    • Our Training Set [训练集]:

    image.png

    • We will start with this ‘’Housing price prediction‘’ example first of fitting linear functions, and we will build on this to eventually have more complex models

    image.png

    2、Cost function

    • 代价函数(平方误差函数):It figures out how to fit the best possible straight line to our data
    • So how to choose θi's ?

    image.png

    • and just try:

    image.png

    • The parameters we choose determine the accuracy of the straight line we get relative to our training set
    • But there is modeling error 建模误差

    image.png

    • Our goal is to select the model parameters that minimize the sum of squares of modeling errors

    • That is to minimize the cost function!image.png

    • summary:

    image.png

    2-1、Cost function introduction I

    • We look up some plots to understand the cost function

    image.png

    2-2、Cost function introduction II

    • Let's take a look at the three-dimensional space diagram of the cost function(also called a convex function 凸函数)

    image.png

    • And here is an example of a contour figure:

    image.png

    • The contour figure is a more convenient way to visualize the cost function

    3、Gradient descent

    • It turns out gradient descent(梯度下降) is a more general algorithm and is used not only in linear regression. I will introduce how to use gradient descent for minimizing some arbitrary function J
    • image.png
    • image.png
    • The formula of the batch gradient descent algorithm :

    image.png

    4、Gradient descent intuition

    • Derivative term purpose :get closer to the minimum

    • image.png

    • Learning rate α

    image.png

    • But what if my parameter θ1 is already at a local minimum?
    • image.png
    • Gradient descent can converge to a local minimum, even with the learning rate α fixed
    • image.png

    5、Gradient descent for linear regression

    • image.png

    • image.png

    • image.png

  • 相关阅读:
    Centos 卸载Docker
    若依微服务版本 Windows下开发环境搭建
    Iterator 其实很简单(最好理解的工厂模式的例子)
    MySQL replace into详解
    MYSQL事务隔离
    Linux下rpm卸载安装MySQL出现specifies multiple packages
    linux删除文件夹的时候出现设备或者资源忙
    IOS下的safari下localStorage不起作用的问题
    windows下nginx配置报错GetFileAttributesEx
    Linux下增加swap的方法
  • 原文地址:https://www.cnblogs.com/wangzheming35/p/14861404.html
Copyright © 2011-2022 走看看