Public
Edited
Nov 5, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof table = {
const table = d3.create("table");

// Add the table header
table.append("thead").append("tr")
.append("th")
.text("Top Words");

// Add the table body and populate it with the first few items
const tbody = table.append("tbody");
tbody.selectAll("tr")
.data(firstFewItems) // Use the first 20 items here
.join("tr")
.append("td")
.text(d => d);

return table.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
firstFewItems = rankedData[0].slice(0, 10)
Insert cell
CU-elements-4.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
CU-elements-GloVe.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

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
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
Insert cell
Insert cell
wordle = words.map (d => d.words)
Insert cell
mutable counter4 = 0;
Insert cell
mutable counter7 = 0;
Insert cell
mutable counter6 = 0;
Insert cell
mutable counter3 = 0;
Insert cell
Insert cell
sheetHeadings = Object.keys(sheet[0])
Insert cell
rankedData = [
// Combine data and scores into an array of pairs, then sort by score
d3.zip(wordle, cosines)
.sort((a, b) => d3.descending(a[1], b[1])) // Sort by scores in descending order
.map(d => d[0]) // Extract the sorted data items
]
Insert cell
Insert cell
Insert cell
listOfVectors = fire.map((_, i) => [earth[i], air[i], water[i], fire[i],wind[i],sun[i],moon[i],mountain[i]])
Insert cell
Insert cell
//import { HorizontalStack } from '@tomktjemsland/inputs'
Insert cell
function cosineSimilarity(vectorA, vectorB) {
if (vectorA.length !== vectorB.length) {
throw new Error("Vectors must be of the same length");
}

let dotProduct = 0;
let magnitudeA = 0;
let magnitudeB = 0;

for (let i = 0; i < vectorA.length; i++) {
dotProduct += vectorA[i] * vectorB[i];
magnitudeA += vectorA[i] * vectorA[i];
magnitudeB += vectorB[i] * vectorB[i];
}

magnitudeA = Math.sqrt(magnitudeA);
magnitudeB = Math.sqrt(magnitudeB);

if (magnitudeA === 0 || magnitudeB === 0) {
return 0;
}

return dotProduct / (magnitudeA * magnitudeB);
}
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
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable counter = 0;
Insert cell
mutable counter5 = 0;
Insert cell
Insert cell
Insert cell
import { analytics } from '@chrispahm/simple-privacy-friendly-web-analytics'
Insert cell
analytics(html`<a href>`.href)
Insert cell
mutable counter2 = 0;
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