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

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