Public
Edited
Apr 14, 2023
Insert cell
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
WordCloud(words, {
width,
height: 500,
fontScale: 1,
invalidation // a promise to stop the simulation when the cell is re-run
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.auto(data_table, {
x: "instruction_len",
y: { value: "response_len", reduce: "mean" },
color: "category",
size: "context_len",
mark: "dot"
}).plot({ color: { legend: true }, x: { type: "log" }, y: { type: "log" } })
Insert cell
Inputs.checkbox(["instruction", "content", "value"])
Insert cell
words = data_table
.slice()
.map((row) =>
text2words(`${row.instruction}\n${row.content}\n${row.response}`)
)
.flatMap((x) => x)
Insert cell
function text2words(text) {
const words = text
.split(/[\s.]+/g)
.map((w) => w.replace(/^[“‘"\-—()\[\]{}]+/g, ""))
.map((w) => w.replace(/[;:.!?()\[\]{},"'’”\-—]+$/g, ""))
.map((w) => w.replace(/['’]s$/g, ""))
.map((w) => w.substring(0, 30))
.map((w) => w.toLowerCase())
.filter((w) => w && !stopwords.has(w));
return words;
}
Insert cell
stopwords = {
const sw = new Set(defaultStopwords);
sw.add("undefined");
return sw;
}
Insert cell
import { WordCloud, stopwords as defaultStopwords } from "@d3/word-cloud"
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