Published
Edited
Oct 4, 2019
Fork of Imports
29 forks
Insert cell
Insert cell
Insert cell
html`mean error: ${meanError}`
Insert cell
Insert cell
Insert cell
Insert cell
printTable(a)
Insert cell
a = {
var a = dataFilt
for(var i = 0;i < dataFilt.length; i++){
a[i].prediction = slope*a[i].x + intercept
a[i].error = Math.abs(a[i].y - a[i].prediction)
}
return a
}
Insert cell
meanError = {
var s = 0
for(var i = 0; i < 10; i++){
s = s + a[i].error
}
return s/dataFilt.length
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataFilt = data.filter(d => d.x >= 150).slice(0,10)
Insert cell
dataPoints = vl.markCircle()
.height(200)
.data(dataFilt)
.encode(
vl.x().fieldQ("x"),
vl.y().fieldQ("y").scale({domain:[0,140]}),
vl.tooltip(["x","y"])
)

Insert cell
line = vl.markLine({stroke:"red"})
.height(200)
.data([{x:0,y:y1},{x:500,y:y2}])
.encode(
vl.x().fieldQ("x"),
vl.y().fieldQ("y").scale({domain:[0,140]})
)
Insert cell
endPoints = vl.markCircle({size:200,stroke:"black",fill:"aqua"})
.height(200)
.data([{x:0,y:y1},{x:500,y:y2}])
.encode(
vl.x().fieldQ("x"),
vl.y().fieldQ("y").scale({domain:[0,140]})
)
Insert cell
intercept = y1
Insert cell
slope = (y2 - y1)/500
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