{
let weight = 0.5;
for (let i = 1; i <= iterations; i++) {
let prediction = input * weight;
let error = Math.pow(prediction - goal, 2);
yield html`
Iteration:${i}<br>
Weight: ${weight}<br>
Error: ${error}<br>
Prediction: ${prediction}
`;
let up = input * (weight + step);
let upError = Math.pow(up - goal, 2);
let down = input * (weight - step);
let downError = Math.pow(down - goal, 2);
if (downError < upError) weight -= step;
if (upError < downError) weight += step;
}
}