Noravshan operatorlar




Download 58,88 Kb.
bet19/19
Sana20.05.2024
Hajmi58,88 Kb.
#245889
1   ...   11   12   13   14   15   16   17   18   19
Bog'liq
Документ Microsoft Office Word

Yechish:
m=0 (dastlabki og’irlik)
𝑏=0 (boshlang'ich qiymat)
𝑎=0,01(o'rganish darajasi)
t=1000 (takrorlanish)

Gradient tushishi:


i 1 dan t gacha













Dastur kodi:
X = np.array([2, 4, 8, 10])
Y = np.array([6, 12, 24, 30])


m = 0
b = 0
𝑎 = 0.01
t = 1000


for i in range(t):
Y_pred = m * X + b
mse = np.mean((Y_pred - Y)**2)
dm = -2 * np.mean(X * (Y - Y_pred))
db = -2 * np.mean(Y - Y_pred)
m -= alpha * dm
b -= alpha * db


X_new = 23
Y_new = m * X_new + b
print("Y(23):", Y_new)



Download 58,88 Kb.
1   ...   11   12   13   14   15   16   17   18   19




Download 58,88 Kb.