我正在嘗試使用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
提交
取消