CHANG machine learning notes 01 (regression)

Regression

1, first of all, what is the regression (regression)

2, then (step machine learning) step to achieve the return of

  step1, model (model determines a) - Linear Model

  step2, goodness of function (the evaluation function determination) - loss function

  step3, best function (a function to find the best) - gradient descent

3, further, how to do better (to optimize step1)

  The method of 1, select another model (another model selection)

  Method 2, consider the hidden factors (to consider other hidden factors)

4, further, to prevent over-fitting (optimization Step2)

  Methods: regularization

5. Finally, summary

 

1, first of all, what is the regression (regression)

  Regression function is to find a function, x via the input features, the output value of a the Scalar .

 

  • Stock Market Forecast (Stock market forecast)

    Input: Changes over the past 10 years, stocks, news consulting, M & A advisory
    output: the average market forecast tomorrow

  • Autopilot (Self-driving Car)

    Input: each unmanned vehicle sensor data, such as road conditions, and other vehicle distance measured
    output: steering wheel angle

  • Product recommendation (Recommendation)

    Input: A characteristic of the product, the characteristics of the merchandise B
    output: the possibility to buy goods B

 

2, then (step machine learning) step to achieve the return of

  For chestnut: We want to predict Pokemon sprites attack.

  Input: CP value before the evolution of the species (Bulbasaur), blood (the HP), the weight (Weight), the height (the Height)
  the CP values of the evolution: output

 

  step1, model (model determines a) - Linear Model

  

  Start with a simple single feature (XCP) starts (hereinafter improved consider more features).

 

 step2, goodness of function (the evaluation function determination) - loss function

  1、确定好model以后,就开始训练数据

  

  以此类推,训练10个数据:

   2、确定损失函数

  有了这些真实的数据,那我们怎么衡量模型的好坏呢?从数学的角度来讲,我们使用距离。求实际进化后的CP值模型预测的CP值差,来判定模型的好坏。

也就是使用 损失函数(Loss function) 来衡量模型的好坏,和越小模型越好。如下图所示:

 

 

 

 step3、best function(找出最好的一个函数)——梯度下降法

   1、找到一个best function(说白了是找最佳的参数),也就是使损失函数最小时候的参数

 

  2、用梯度下降法,求最佳参数  

  1)梯度是什么?梯度下降又是什么?

  梯度

  • 在单变量的函数中,梯度其实就是函数的微分,代表着函数在某个给定点的切线的斜率
  • 在多变量函数中,梯度是一个向量,向量有方向,梯度的方向就指出了函数在给定点的上升最快的方向

  梯度下降:“下山最快路径”的一种算法

  2)先考虑简单的一个参数w

 

 

  首先在这里引入一个概念 学习率 :移动的步长,如图7中 η (eta)

  步骤1:随机选取一个 w0 。
  步骤2:计算微分,也就是当前的斜率,根据斜率来判定移动的方向。
     大于0向右移动(增加w)
     小于0向左移动(减少w)
  步骤3:根据学习率移动。
  重复步骤2和步骤3,直到找到最低点。


  3)再考虑两个参数(w、b)

 

  3、梯度下降法的效果

  颜色约深的区域代表的损失函数越小

  

   4、梯度下降的缺点

    总结一下梯度下降法:我们要解决使L(x)最小时参数的最佳值,梯度下降法是每次update参数值,直到损失函数最小。

 

  但是梯度下降法会出现问题呢?

 

  step4、回归结果分析

  经过上述三个步骤后,我们就得到了训练后的“最佳参数w,b”,那么它在测试集的performance怎么样呢?下面一起来看看吧

 

  

  如何优化呢?继续看吧

 

3、进一步,如何做得更好(优化step1欠拟合)

  方法1、select another model(选择另一个模型)

  1、model改用不同函数的performance:

       

 

  2、如何选择model呢

 

 

 

  超过三次函数以上的model都出现了过拟合问题,因此要找到一个suitable model(这里是第三个)

  方法2、consider the hidden factors(考虑其他隐藏因素)

  1、再考虑另外一个因素(精灵的种类)

  

 

   performance:

 

 2、把更多的因素都考虑

 

              

 

   考虑更多的因素反而出现了过拟合的问题,说明有些因素跟本次实验的CP值预测没有关系

   过拟合这么讨厌,到底如何减少过拟合问题呢?往下看!

4、再进一步,防止过拟合(优化step2)

  方法:正则化

  1、比如先考虑一个参数w,正则化就是在损失函数上加上一个与w相关的值,使function更加平滑(function没那么大跳跃)

  2、正则化的缺点

  正则化虽然能够减少过拟合的现象,但是因为加在损失函数后面的值是平白无故加上去的,所以正则化过度的话会导致bias偏差增大

  

  5、最后,总结

 

Guess you like

Origin www.cnblogs.com/xxlad/p/11198853.html