Platform
Resources
Pricing
Sign in
Get started
Charles Boisvert
Workspace
Fork
Published
By
Charles Boisvert
Edited
Feb 13, 2020
Fork of
My neural network
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.
Try it for free
Learn more
Compare fork
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
SIZE
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
rand
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randPoint
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
team
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
getPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomPoints
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
randomWeights
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
predict
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
classifyPoint
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
train
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML