Logistic Regression代价函数权值更新的代码实现

data_matrix是  m×n 的矩阵,label_matrix是 m×1 的矩阵,h是预测得到的矩阵,error是 m×1 的预测与标签的误差矩阵,weights是 n×1 的权值矩阵,学习率为alpha

那么logistic regression的权值更新可写为:

error = h - label_matrix

weights = weights - alpha * data_matrix.transpose()*error

猜你喜欢

转载自blog.csdn.net/qq_17478877/article/details/80159800
今日推荐