Machine Learning ---- Cost function

        The most important step in building a linear regression model is to construct a cost function, as the cost function tells us how well the model is done, so that we can try to fit the parameters of the model better. As one of the most common and important concepts in machine learning, cost function is used for linear regression and training many advanced Al models in the world.

        When fitting a univariate regression equation, we need to solve for the values of the two parameters w and b, and we can use the cost function to determine whether (w, b) is optimal or the best case:

        f(x_i) = wx_i + b

      At this point, we can use the cost function to:

        J(\theta_0,\theta_1) = \frac{1}{2m}\sum_{i = 1}^{m}(h(x^{(i)}) - y^{(i)})^2

        when meeting  minJ(\theta_0,\theta_1) ,the optimal (w, b) solution can be obtained.

        If it is one parameter, the cost function can generally be intuitively seen through a two-dimensional curve. If there are two parameters, the cost function can be seen from the three-dimensional image, and the more parameters, the more complex it becomes.

        When there are 2 parameters, the cost function is a three-dimensional image. As shown in the following figure:

        Among them, the height is the value of the cost function. At this point, we can take the solution of (w, b) on the graph and fit the first-order regression equation to observe the degree of error of the corresponding first-order equation.

        Of course, as a cost function used to fit regression equations, it has limited applicability to training algorithms. Therefore, to address this issue, we have also proposed a more efficient training method, namely gradient descent. In the next section, we will bring you the relevant knowledge of gradient descent.

最近更新

  1. TCP协议是安全的吗?

    2024-03-16 07:18:05       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-16 07:18:05       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-16 07:18:05       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-16 07:18:05       18 阅读

热门阅读

  1. SQL zoo(zh)习题记录Ⅰ

    2024-03-16 07:18:05       20 阅读
  2. 服务器生产环境问题解决思路

    2024-03-16 07:18:05       19 阅读
  3. MapReduce超详解

    2024-03-16 07:18:05       18 阅读
  4. CMake官方教程6--为CDash提供支持

    2024-03-16 07:18:05       17 阅读
  5. ZooKeeper 概述

    2024-03-16 07:18:05       24 阅读
  6. with open----bug

    2024-03-16 07:18:05       18 阅读
  7. 获取iOS和Android的app下载渠道和相关参数的方式

    2024-03-16 07:18:05       17 阅读
  8. 手写 UE4中的 TArray

    2024-03-16 07:18:05       17 阅读