Published
Edited
Mar 13, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ticking = 1
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
allData = {
const redData = tf.randomNormal([NPOINTS, 2], 2, 2)
console.log(redData)
const redLabels = tf.zeros([NPOINTS])
const blueData = tf.randomNormal([NPOINTS, 2], -2, 2)
const blueLabels = tf.ones([NPOINTS])
let flatArray = Array.from(redData.concat(blueData).dataSync())
let trueLabels = Array.from(redLabels.concat(blueLabels).dataSync())
let fullArray = []
for (let i = 0; i < flatArray.length; i += 2) {
fullArray.push({
"id": i / 2,
"x": flatArray[i],
"y": flatArray[i+1],
"label": trueLabels[i / 2],
"labelled": false
})
}
return fullArray
}
Insert cell
Insert cell
unlabelledData = allData.filter(d => labels.indexOf(d["id"]) < 0)
Insert cell
labelledData = labels.map(index => allData[index])
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
xScale = d3.scaleLinear()
.domain([-8,8])
.range([margin.left, size.width - margin.right])
Insert cell
yScale = d3.scaleLinear()
.domain([-8, 8])
.range([size.height - margin.bottom, margin.top])
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