I am getting index out of bonds error, while I am trying to perform derivative on Slope
Пробовал с использованием (итераций-1) и (итераций + 1), но все равно та же ошибка
WEI=0
# print(WEI)
BIA=0
# # print(BIA)
learning_rate=0.0001
I am getting index out of bonds error, while I am trying to perform derivative on Slope
iterations=1000
len_df=len(y_train)
cost_array=[]
for i in range(iterations):
y_pred=WEI*X_train+BIA
# Derivative of the cost function w.r.t slope (WEI)
WEI+=-2*X_train[i]*(y_train[i]-(WEI*X_train[i]+BIA))
# Derivative of the cost function w.r.t intercept (BIA)
BIA+=-2*(y_train[i]-(WEI*X_train[i]+BIA))
# move WEI & BIA
WEI-=(WEI/float(len_df))*learning_rate
BIA-=(BIA/float(len_df))*learning_rate
print(WEI)
print(BIA)