zoukankan      html  css  js  c++  java
  • ufldl学习笔记与编程作业:Logistic Regression(逻辑回归)

    ufldl学习笔记与编程作业:Logistic Regression(逻辑回归)


    ufldl出了新教程,感觉比之前的好,从基础讲起。系统清晰,又有编程实践。

    在deep learning高质量群里面听一些前辈说。不必深究其它机器学习的算法,能够直接来学dl。

    于是近期就開始搞这个了,教程加上matlab编程,就是完美啊。

    新教程的地址是:http://ufldl.stanford.edu/tutorial/


    本节学习链接:http://ufldl.stanford.edu/tutorial/supervised/LogisticRegression/


    有了线性回归的基础再来学这个。简直是easy啊。

    线性回归一般是拟合,预測的输出一般是连续的。

    而逻辑回归通常来做离散的预測,比方二值的0或者1,也就是分类问题。


    搞懂了目标函数和偏导数后,就能够编程了。


    编程题目是对手写数字0和1做分类。

    logistic_regression.m代码例如以下

    function [f,g] = logistic_regression(theta, X,y)
      %
      % Arguments:
      %   theta - A column vector containing the parameter values to optimize.
      %   X - The examples stored in a matrix.  
      %       X(i,j) is the i'th coordinate of the j'th example.
      %   y - The label for each example.  y(j) is the j'th example's label.
      %
    
      m=size(X,2);
      
      % initialize objective value and gradient.
      f = 0;
      g = zeros(size(theta));
      
      h = sigmoid(X'*theta);
      f=-y*log2(h)+(1-y)*log2(1-h);
      g=X*(h-y');
      %
      % TODO:  Compute the objective function by looping over the dataset and summing
      %        up the objective values for each example.  Store the result in 'f'.
      %
      % TODO:  Compute the gradient of the objective by looping over the dataset and summing
      %        up the gradients (df/dtheta) for each example. Store the result in 'g'.
      %
    %%% YOUR CODE HERE %%%
    

    结果例如以下:


    教程里说准确率应该是100%,我这里居然是99.7%和99.9%。

    难道我做错了。。

    假设由谁做到100%,记得告诉我啊。


    本文作者:linger

    本文链接:http://blog.csdn.net/lingerlanlan/article/details/38390085




  • 相关阅读:
    WPF数据绑定之Ado.net的数据库连接绑定
    asp.net 网站js弹出提示后原页面css样式丢失
    Javascript中函数重载的实现
    JavaScript的继承
    WPF数据绑定之4种绑定模式
    Asp.net输出Excel文件并且下载该文件以及某些细节问题解决
    js 验证身份证 带X
    WPF的数据绑定之控件源绑定以及代码方式绑定
    WPF数据绑定之DataContext
    在无cookie模式中,会话话状态的ID将会自动保存在ASP.NET的查询字符串中
  • 原文地址:https://www.cnblogs.com/wzzkaifa/p/6903717.html
Copyright © 2011-2022 走看看