线性回归(Linear)
损失函数(平方损失函数):
梯度下降更新参数:
添加正则化的损失函数:
python实现:
def grad_descent(dataMatIn, classLabels):
dataMatrix = np.mat(dataMatIn)
labelMat = np.mat(classLabels).transpose()
n, m = np.shape(dataMatrix)
weights = np.ones((m, 1)) #(m, 1)
alpha = 0.001
maxCycle = 500
for i in range(maxCycle):
h = dataMatrix * weights
weights = weights - alpha * dataMatrix.transpose() * (h - labelMat)
return weights
逻辑回归(LR)
https://blog.csdn.net/moxigandashu/article/details/72779856
通过sigmoid函数映射线性回归函数结果:
sigmoid函数求导:
对数似然函数: ![J(\theta)=-\frac{1}{m}[\sum_{i=1}^{m}y^{(i)}logh_\theta(x^{(i)})+(1-y^{(i)})log(1-h_\theta(x^{(i)}))]](https://i-blog.csdnimg.cn/blog_migrate/28becc6207003846b1e967767ee20e42.gif)
本文涵盖了线性回归、逻辑回归、朴素贝叶斯、BP神经网络、K-近邻算法、K-means等常见机器学习模型的原理、损失函数、优化方法以及Python实现。同时介绍了pytorch和Keras的基本框架应用。

最低0.47元/天 解锁文章
8万+

被折叠的 条评论
为什么被折叠?



