每天30行代码——随机梯度上升算法
2017-11-26 22:27
274 查看
梯度上升算法每次更新回归系数时都要遍历整个数据集,在样本数较少时还可以,当样本数目太多时复杂度太高,所以产生了随机梯度上升算法,每次仅用一个样本点来更新回归系数。
def stocGradAscent0(dataMatrix,classLabels): m,n=shape(dataMatrix) alpha=0.01 weights=ones(n) for i in range(m): h=sigmoid(sum(dataMatrix[i]*weights)) error=classLabels[i]-h weights=weights+alpha*error*dataMatrix[i] return weights
相关文章推荐
- 每天30行代码——Logisstic回归梯度上升算法
- 每天一道算法题(1)——在二元树中找出和为某一值的所有路径(java代码)
- 算法代码hdu 1025(最大上升子序列的n*logn解法)
- [机器学习]Logistic回归梯度上升法与改进的随机梯度上升算法
- 逻辑斯特回归(随机梯度上升算法)预测马疝病的死亡率问题
- 每天写一点代码----字符串匹配算法 2 (BM算法)
- 机器学习-Logistic回归之使用随机梯度上升算法预测病马死亡率
- 机器学习——分类算法4:Logistic回归 梯度上升 思想 和 代码解释
- SVN实现代码的上传与下载(注意在公司中,必须每天都要把代码上传一次)
- 每天写出好代码的5个建议
- RANSAC(随机采样一致算法)原理及openCV代码实现
- 经典面试题(一)附答案 算法+数据结构+代码 微软Microsoft、谷歌Google、百度、腾讯
- 每天写出好代码的5个建议
- 『HTML5实现人工智能』小游戏《井字棋》发布,据说IQ上200才能赢【算法&代码讲解+资源打包下载】
- clojure实现最长上升子序队列算法
- CRC算法之二:具体实现代码
- 每天写出好代码的5个建议
- 30行,金额转人民币大写的代码
- 【每天一道算法题】给定一个存放整数的数组,要求数组左边为奇数,右边为偶数
- 每天学习算法系列—内部排序之归并排序和快速排序