Published
Edited
Nov 23, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
msePartialw = (w,b) => {
const summand = X.map((x,i) => (Y[i]-w*X[i]-b)*X[i])
return -2*d3.sum(summand)/4
}
Insert cell
msePartialb = (w,b) => {
const summand = X.map((x,i) => (Y[i]-w*X[i]-b))
return -2*d3.sum(summand)/4
}
Insert cell
Insert cell
coordinates = {
const coordinates = []
let w = w0
let b = b0
for(let i = 0; i <= 1000; i = i + 1){
coordinates.push([w,b])
w = w - .01*msePartialw(w,b)
b = b - .01*msePartialb(w,b)
}
return coordinates
}
Insert cell
w = coordinates[step][0]
Insert cell
b = coordinates[step][1]
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