经过对Logistic回归理论的学习,推导出取对数后的似然函数为

现在我们的目的是求一个向量,使得最大。其中

对这个似然函数求偏导后得到

根据梯度上升算法有

进一步得到

我们可以初始化向量为0,或者随机值,然后进行迭代达到指定的精度为止。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjMAAAGMCAIAAACgRLSoAAAgAElEQVR4nO3d3aGkqtquYRNYx18KMwazWEmQx8yABHYaHK1MCMZ94E+hggKCvDju66i7ukcJDIpHEK1hAgBAkqF1AQAA2HmUTNbaUuUoyupRmayf0zk/VppRMaVPLmxuqwDAyx4lk1HDMAxKqVHb3au7vy+veUZFq0fvf939X6OGwffDt+VK/KHt504lqsTowIGM2pfC6vFcGavHxLLOP5HeKgDwsifJtGbIMuTtKLPEw+41/3vsh1ffu41jyvzgMsuuphrHUKxoaR1vsniKMTeK86LVY2pRvecBACDPg2TaBtD9KOkbMy/G0VM0HQfQc3Zds3oM/sCaev6y5A/dvjS9tpTAm5PegNxXyz8HvS8kyQSgA/nJ9Bs/HyXT6aqKbzXPN6BepYHS/n9c38d/JScwZTLGFx6RwZAzDQuVY1s0da4YJVzqCydTdG0A4A3ZyeRcTXqWTAen8TNtzpQ6wzoceV+N+Y1CERh1mAfJdFrB+/37NuM6XTlKn70dZnEA0FxuMrnXckom0/nEPiVr0nNpP5KP43gerj2F923yCJcoqubnSJmPcL5c97uGt5TBN6kLvP2oTeg6m9SNlgD+nsxk2g2Np0F11Pb8YmB8tnp0BnnfQH4cm4MD/UUuXV188h/6Fz7vJNP+Ry42cCTvfNjec/7NWK242ARAtKxksnoclRr9c6bIN/CkTeaou5gH9NAFpnEcRqVNeEg+HNyZuz1OprtE9f1EXDJZc1Gj/Q/NTTNqy2UlANLlJJNRo7bOEBmTKMG1onWQ38+dzv/p+gjXm+6miCw5/AfniIXmTGsRb37QDe3get5xgnpfhuU3tr4je/QACJaeTMtq0CGZdvMf/2X40L4wZ4npehC+iZ3L+LrLksMPu2lUcjXPWVXz/38nYo833AYKc3d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48Eb7WJ3NMt9CA1mWKHqu3Ci9XazD+2/tzySq7iPf57NSooqWxGa+O94Gb12CIfguWZ1uXYvzejumqTsgeSe7qFDiQnU+RQta4ZrJOJbRx/tOy1vFPZHv+9GpUUudg5TZNRyiwj/tyc1hg7bRnwehVD5ZmmyepxeemVQXo7qC8I015+6KJNCovvN4BHcjLFdrl58WtcJxN2vizzeBSv0eO/V6OSbnJzDeh5zHNGVKOcH3svfGPK4w7Hr03n1i2eh7BJezlP3O+oKMnrAOhBejJFjjJGDYPSdret2nd66mxyc67kBFXp8QVrlFidqYPP8HXrnIZQ75h6eI/0VooWVx5v0SqW6leQFnOm6N/R8tJvofo3u0prHPGdGtJlJFPcQH48Hbv4ogejRm3nf7/7OohKPb5ojRKqM3XxGS5QxHMDp7VSPfsZq5RSNWLUqLUalDFqvudp+ZPd/jWucYQvA6ADOclUeDSdPw7r2dhlj67W4wvWKKE6Uyef4ecrXqeWSGulevanG1JK1YhRo1LazL1SKaWt+8GIb5y/2HYoLCuZii7Ou5djb4bpij2+WI0SqjP18xl+mtzHeqa1UjXrhRdZpWrF2dMzOn/agimycXrp0xAtL5kKTjKcfnwzGlTu8WVqFF+dqa/P8LPmOV9nim+lWrYNeqJK1c62Qvf7Ve+DKapxeurTECw3mUqN5E4vb34mVqBG0dWZ+vsMP5lW7uua0kq1uMt489RJQqka+l068v0psnF669MQKz+ZiqyAub18fdik7w1f6vFPaxRbnanTz3BWdjtPxD0vBt20Uh3uc7e3cjUvVVu/6u+CaWmdqMbpsktDqCfJNL20s+zVHv+9GhXWc9lRzV/cyoiKHibTNNUeqlr0+O/VqCwelIofegMqKJBMU6XO2bTHf69GANCLMskEAEApJBMAQBaSCQAgC8kEAJCFZAIAyEIyAQBkIZkAALKQTAAAWUgmAIAs/x+oi1NtNJ3h6wAAAABJRU5ErkJggg==" alt="" width="492" height="346" />

 def sigmoid(inX):
return 1.0/(1+exp(-inX))
 def gradAscent(dataMatIn, classLabels):
dataMatrix = mat(dataMatIn) #convert to NumPy matrix
labelMat = mat(classLabels).transpose() #convert to NumPy matrix
m,n = shape(dataMatrix)
alpha = 0.001
maxCycles = 500
weights = ones((n,1))
for k in range(maxCycles): #heavy on matrix operations
h = sigmoid(dataMatrix*weights) #matrix mult
error = (labelMat - h) #vector subtraction
weights = weights + alpha * dataMatrix.transpose()* error #matrix mult
return weights

Logistic回归,梯度上升算法理论详解和实现的更多相关文章

  1. logistic回归梯度上升优化算法

    # Author Qian Chenglong from numpy import * from numpy.ma import arange def loadDataSet(): dataMat = ...

  2. [PXE] Linux(centos6)中PXE 服务器搭建,PXE安装、启动及PXE理论详解

    [PXE] Linux(centos6)中PXE 服务器搭建,PXE安装.启动及PXE理论详解 本篇blog主要讲述了[PXE] linux(centos)PXE无盘服务器搭建,安装,启动及pxe协议 ...

  3. JVM的GC理论详解

    GC的概念 GC:Garbage Collection 垃圾收集.这里所谓的垃圾指的是在系统运行过程当中所产生的一些无用的对象,这些对象占据着一定的内存空间,如果长期不被释放,可能导致OOM(堆溢出) ...

  4. Logistic 回归梯度上升优化函数

    In [183]:           def loadDataSet(): dataMat = [] labelMat = [] fr = open('testSet.txt') for line ...

  5. awk理论详解、实战

    答疑解惑: 为什么用awk取IP的时候用$4? ifconfig eth0 | awk -F '[ :]+' 'NR==2{print $4}' IP第二行内容如下: inet addr:10.0.0 ...

  6. 边框回归(Bounding Box Regression)详解

    原文地址:http://blog.csdn.net/zijin0802034/article/details/77685438 Bounding-Box regression 最近一直看检测有关的Pa ...

  7. [转]边框回归(Bounding Box Regression)详解

    https://blog.csdn.net/zijin0802034/article/details/77685438 Bounding-Box regression 最近一直看检测有关的Paper, ...

  8. 【边框回归】边框回归(Bounding Box Regression)详解(转)

    转自:打开链接 Bounding-Box regression 最近一直看检测有关的Paper, 从rcnn, fast rcnn, faster rcnn, yolo, r-fcn, ssd,到今年 ...

  9. Java基础学习总结(53)——HTTPS 理论详解与实践

    前言 在进行 HTTP 通信时,信息可能会监听.服务器或客户端身份伪装等安全问题,HTTPS 则能有效解决这些问题.在使用原始的HTTP连接的时候,因为服务器与用户之间是直接进行的明文传输,导致了用户 ...

随机推荐

  1. poj1088滑雪最短路径

    滑雪 Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 97281   Accepted: 36886 Description ...

  2. AI决策算法 之 GOAP (二)

    http://blog.csdn.net/lovethRain/article/details/67634803 GOAP 的主要逻辑: 1.Agent的状态机初始化Idle状态 2.Idel状态根据 ...

  3. codeforces986F Oppa Funcan Style Remastered【线性筛+最短路】

    容易看出是用质因数凑n 首先01个因数的情况可以特判,2个的情况就是ap1+bp2=n,b=n/p2(mod p1),这里的b是最小的特解,求出来看bp2<=n则有解,否则无解 然后剩下的情况最 ...

  4. gitlab之source tree使用方法

    一.简介 1.source tree 是什么 可视化项目版本控制软件,使用git项目管理,支持windows/mac 客户端使用source tree开发源码,图形化提交到gitlab 二.使用sou ...

  5. C 语言实例 - 判断数字为几位数

    C 语言实例 - 判断数字为几位数 用户输入数字,判断该数字是几位数. 实例 #include <stdio.h> int main() { long long n; ; printf(& ...

  6. Unity 打包PC和安卓的路径注意事项

    if UNITY_STANDALONE_WIN || UNITY_EDITOR return Application.persistentDataPath + "/LocalData&quo ...

  7. 51nod 1515 明辨是非 并查集+set维护相等与不等关系

    考试时先拿vector瞎搞不等信息,又没离散化,结果好像MLE:后来想起课上讲过用set维护,就开始瞎搞迭代器...QWQ我太菜了.. 用并查集维护相等信息,用set记录不相等的信息: 如果要求变量不 ...

  8. Spark Mllib里如何记录开始训练时间、完成训练时间、所需训练时间(图文详解)

    不多说,直接上干货! 具体,见 Hadoop+Spark大数据巨量分析与机器学习整合开发实战的第16章 朴素贝叶斯二元分类算法来预测分类StumbleUpon数据集

  9. 《java学习二》jvm性能优化-----认识jvm

    Java内存结构 Java堆(Java Heap) java堆是java虚拟机所管理的内存中最大的一块,是被所有线程共享的一块内存区域. 在虚拟机启动时创建.此内存区域的唯一目的就是存放对象实例,这一 ...

  10. 在ubuntu 12.04上安装tomcat 7.40

    因为源上的版本问题,所以没有使用源上的自动安装包,老规矩,Tomcat 7.0.40 Core下载地址:http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/ ...