Published
Edited
Feb 13, 2020
Insert cell
md`# My neural network (part)
After following funfunfunction https://www.youtube.com/watch?v=o98qlvrcqiU`
Insert cell
SIZE=400
Insert cell
rand = (lo,hi)=>(lo+Math.random()*(hi-lo))
Insert cell
html`
<svg width="${SIZE}" height="${SIZE}">
<line x1="0" x2="${SIZE}" y1="0" y2="${SIZE}" stroke="purple" />
</svg>
`
Insert cell
randPoint = ()=>({x:rand(0,SIZE),y:rand(0,SIZE)})
Insert cell
team = (p) => ( p.x<p.y?1:-1 )
Insert cell
getPoints = (n) => (Array.from({length: n}, randPoint)) // R.range(0,n).map(randPoint))
Insert cell
randomPoints = getPoints(300)
Insert cell
randomWeights = ({
x: rand(-1,1),
y: rand(-1,1)
})
Insert cell
Insert cell
classifyPoint = (point)=>{point.team = team(point); return point}
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