Published
Edited
Aug 27, 2021
Fork of Simple D3
3 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
thresholdView = slider({
min: 0.2,
max: 1,
value: 0.3,
step: 0.1,
description: md`Neighbourhood Threshold`,
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
eigs = mathjs.eigs(laplacian)
Insert cell
eigs.values
Insert cell
numberOfClusters = eigs.values.filter(e => e <= eigValueThreshold).length
Insert cell
Insert cell
clusterAssignment = {
const clusterAssignment = Array.from({ length: data.length }).map(u => 0)
for (let i = 1; i < numberOfClusters; i++) {
const ev = mathjs.transpose(eigs.vectors)[i]
const embedding = mathjs.multiply(normalizedMatrix, ev)
embedding.forEach((magnitude, j) => {
if(magnitude > 0) {
clusterAssignment[j] = i
}
})

}
return clusterAssignment
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
showConnectionsView = Inputs.toggle({label: "Show Connections", value: true})
Insert cell
Insert cell
showClusterLabelView = Inputs.toggle({label: md`Show Clusters`, value: true})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataMax = Math.ceil(mathjs.max(mathjs.abs(data)))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mathjs = require('https://unpkg.com/mathjs@6.6.0/dist/math.min.js')
Insert cell
import {dataset_swiss_roll} from "@heytitle/stein-variational-gradient-descent"
Insert cell
import {slider} from "@jashkenas/inputs"
Insert cell
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