|
Noravshan operatorlar
|
bet | 19/19 | Sana | 20.05.2024 | Hajmi | 58,88 Kb. | | #245889 |
Bog'liq Документ Microsoft Office WordYechish:
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)
|
| |