Public
Edited
Jul 7, 2023
1 fork
5 stars
Insert cell
Insert cell
Insert cell
lc = require("linearcorrelation")
Insert cell
Insert cell
geom = FileAttachment("world.geojson").json()
Insert cell
data = FileAttachment("basics.csv").csv({ typed: true })
Insert cell
Insert cell
Insert cell
Insert cell
bertin = require("bertin")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
grid: true,
x: {
type: xlog ? "log" : undefined
},
marks: [
Plot.dot(data, {
x: "gdppc",
y: "esp",
fill: "#53a6c9",
tip: true,
title: (d) => [d.name, "esp: " + d.esp, "gdppc: " + d.gdppc].join("\n")
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
lc.test(data, { x: "gdppc", y: "esp", logx: true })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
grid: true,
x: {
type: xlog ? "log" : undefined
},
marks: [
Plot.dot(data, {
x: "gdppc",
y: "esp",
fill: "#53a6c9",
tip: true,
title: (d) => [d.name, "esp: " + d.esp, "gdppc: " + d.gdppc].join("\n")
}),
Plot.linearRegressionY(data, {
x: "gdppc",
y: "esp",
stroke: "#783c74"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
residuals_norm = regression.data.map((d) => d.residuals_norm)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
SimpleLinearRegression = import(
"https://cdn.skypack.dev/ml-regression-simple-linear@2.0.3?min"
).then((d) => d.default)
Insert cell
reg = new SimpleLinearRegression(x, y)
Insert cell
reg.toString()
Insert cell
reg.score(x, y)
Insert cell
Insert cell
ss = require("simple-statistics")
Insert cell
sample = data2.map((d) => [d.gdppc_log, d.esp])
Insert cell
corr = ss.sampleCorrelation(x, y)
Insert cell
lm = ss.linearRegression(data2.map((d) => [d.gdppc_log, d.esp]))
Insert cell
linearRegressionLine = ss.linearRegressionLine(lm)
Insert cell
+ss.rSquared(sample, linearRegressionLine).toFixed(4)
Insert cell
Insert cell
d3 = require("d3", "d3-regression")
Insert cell
linearRegression = d3
.regressionLinear()
.x((d) => d.gdppc_log)
.y((d) => d.esp)
Insert cell
espgdpregression = linearRegression(data2)
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