Public
Edited
Jul 24, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
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;
}
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more