Published
Edited
Mar 16, 2020
1 fork
Insert cell
Insert cell
{
const { NeuralNetwork } = brain;
const net = new NeuralNetwork();
net.train([
{
input: normalize([1,2,3,4,5]),
output: normalize([3])
},
{
input: normalize([2,3,4,5,6]),
output: normalize([4])
},
{
input: normalize([3,4,5,6,7]),
output: normalize([5])
},
{
input: normalize([4,5,6,7,8]),
output: normalize([6])
},
]);
return denormalize(net.run(normalize([2,3,4,5,6])));
}
Insert cell
function normalize(values) {
return values.map(value => value / 6);
}
Insert cell
function denormalize(values) {
if (Array.isArray(values)) {
return values.map(value => value * 6);
}
return values * 6;
}
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