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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more