brain.js
brain.js copied to clipboard
brain.js not oututting any real results - what should I do
I am trying to build an AI to make predictions about climate data using brain.js, however, when I plug it into a neural network, nothing happens - it always returns [1,1,1,1,1,1,1,1]. I saw an answer online that said to increase samples, but I am not sure how I can do this. Can someone please explain?
My HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<p>TEst</p>
<script src="https://unpkg.com/brain.js"></script>
<div id="output"></div>
<script src="script.js"></script>
</head>
<body>
</body>
</html>
My js:
const net = new brain.NeuralNetwork()
net.train([
{
input: [2004],
output: [11500.0,2070.0,2415.0,0.0,0.0,4255.0,690.0,2070.0]
},
{
input: [2005],
output: [11500.0,2070.0,2415.0,0.0,0.0,4255.0,690.0,2070.0]
},
{
input: [2006],
output: [24651.0,4190.67,4930.2,0.0,0.0,12325.5,1232.55,1972.08]
},
{
input: [2007],
output: [25100.0,3765.0,4769.0,0.0,0.0,13052.0,1506.0,2008.0]
},
{
input: [2008],
output: [24997.0,3499.58,5499.34,0,0,13248.41,1499.82,1249.85]
},
{
input: [2009],
output: [26682.0,3468.66,5603.22,0,0,14941.92,1600.92,1067.28 ]
},
{
input: [2010],
output: [25800.0,3354,5160,0,0,14964,1290,1032]
},
{
input: [2011],
output: [26538.0,0,4246.08,265.38,13799.76,6369.12,0,1326.9]
},
{
input: [2012],
output: [26020.0,1821.4,3903,0,0,18994.6,1040.8,260.2]
},
{
input: [2013],
output: [26236.0,1311.8,6034.28,0,0,17578.12,1311.8,0]
},
{
input: [2014],
output: [27055.0,1352.75,6222.65,0,0,18397.4,1082.2,0]
},
{
input: [2015],
output: [26073.0,1303.65,5736.06,0,0,17990.37,1042.92,0]
},
{
input: [2016],
output: [26836.0,805.08,6172.28,0,0,18785.2,1073.44,0]
},
{
input: [2017],
output: [26653.0,533.06,6130.19,0,0,18923.63,1066.12,0]
},
{
input: [2018],
output: [24586.0,491.72,5408.92,245.86,0,17947.78,491.72,0]
},
{
input: [2019],
output: [27515.0,0,6053.3,550.3,0,20361.1,550.3,0]
},
{
input: [2020],
output: [28411.0,0,6250.42,852.33,0,20740.03,568.22,0]
},
{
input: [2021],
output: [28564.0,0,6284.08,1713.84,19.9948,19994.8,19.9948,19.9948]
}
])
let data = net.run([2022]);
let output1 = document.getElementById('output');
output1.innerHTML = data;
You have to normalize your data. If the neural network runs on a sigmoid activation function, it can only output values between 0 and 1. Introduce scales for input and output and normalize your values accordingly.