逻辑回归模型:

  want: 0 <= hθ(x)<=1

  hθ(x) = g(θTx)     //θ 注意有个θ一般置1

  g(z) = 1 / (1+e-z)    //sigmoid 函数

由sigmoid函数特性(2分类问题):

  当θTx>= 0 时,hθ(x)>= 0.5 , 预测 y =1 ;

  当θTx< 0 时,hθ(x)< 0.5 , 预测 y = 0 ;

ps: 可以改变阈值, 此处为0.5,取决于需要的置信度高低

决策边界:

  θT.X == 0   对应上面阈值为 0.5     不一定是直线,看特征向量怎么选  平方 x1*x2

csot function:

  J(θ) = 1/m Σ(-y log( hθ(X) ) - (1 - y)log( 1 - hθ(X) ))+ (λ /2m)∑j=1n θ2j    //m为样本数  可进行向量化    红色部分为正则项

目标:

  min(J(θ))

  使用梯度下降

  Repeat:

    θj := θj - α(Σ(hθ(xi) - yi) xij + (λ /m)θj)

    注意: θ要“同时“赋值, 因为求下降的部分用到了 hθ(xi) 而hθ(xi)里面用到θ 

        即是在山上一个位置同时对各个方向求偏导   如果不同时  那么 位置就变了

 

优化:

  overfit :  reduce  feature, bigger dataset,increase penalize parameter λ

  underfit:  increase feature, reduce penalize parameter λ

  How to choose learning rate α ?

    By iteration and draw the picture of cost function and times of iteration

    

内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!