Published
Edited
Dec 3, 2021
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Yhat = X.map(x => slope*x + intercept)
Insert cell
differences = X.map((x,i) => Y[i] - Yhat[i])
Insert cell
squares = differences.map(d => d*d)
Insert cell
mse = d3.mean(squares)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
X = result.sh
Insert cell
Y = result.pts
Insert cell
label = result.name
Insert cell
Insert cell
Insert cell
Insert cell
plotInfo = ({
x:{domain:[0,30]},
y:{domain:[0,10]},
marks:[
Plot.ruleX([0]),
Plot.ruleY([0]),
Plot.line([
[0,slope*0 + intercept],
[30,slope*30 + intercept]
],{stroke:"red"}),
Plot.dot(X,{x:X,y:Y,fill:"black",r:5,title:(d,i) => label[i]})
]
})
Insert cell
Insert cell
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