我正在尝试使用g1作为类0和g2作为类1进行逻辑回归:ft=np.vstack((g1,g2)) #data stacked on each otherclass = np.hstack((np.zeros(f), np.ones(f))) #class values in column matrixclc=np.reshape(cl,(2*f,1)) #class values in an arrayw=np.zeros((2,1)) #weights matrixfor n in range(0,5000): s = np.dot(ft, w) prediction = (1 / (1 + np.exp(-s))) #sigmoid function gr = (np.dot(ft.T, class - prediction)) #gradient of loss function w += 0.01 * grprint (w)我使用sklearn评估结果:from sklearn.linear_model import 我得到:w = [[6.77812323] [2.91052504]]coef _ = [[1.22724506 1.10456893]您知道重量为什么不匹配吗?我的数学有什么问题吗?
添加回答
举报
0/150
提交
取消