question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LSTMTimeStep forecast always descending or ascending consecutive numbers

See original GitHub issue

What is wrong?

Maybe it’s something wrong in my code but I expected that every forecast for each day predict based on the past days not always a descending or ascending numbers from the first day.

Where does it happen?

  • Windows 10
  • Node.js v12.16.2
  • brain.js@2.0.0-alpha.12

How do we replicate the issue?

  • The data is normalized
  • At 60k interactions get errorThresh = 0.005
  • There is no error, just the forecast output always are descending or ascending consecutive numbers

Code sample:

const netOptions = {
	inputSize: 4,
	hiddenLayers: [20, 20],
	outputSize: 4
};

const net = new brain.recurrent.LSTMTimeStep(netOptions);

const trainingOptions = {
	iterations: 1000, 
	errorThresh: 0.002,
	learningRate: 0.005
};

const trainingData = [
  [
	...9k more data
    {
      close: 0.3672922007633208,
      open: 0.3753351139350292,
      high: 0.37622875109510723,
      low: 0.3603217093776281
    },
    {
      close: 0.37819481004120087,
      open: 0.37319032398229984,
      high: 0.3817694480470161,
      low: 0.36872204881640663
    }
  ]
];

const stats = net.train(trainingData, trainingOptions);

const toPredictData = [
		normalData.slice(-40, -20),
	];

const forecast = net.forecast([
	toPredictData[0][0],
	toPredictData[0][1],
	toPredictData[0][2],
	toPredictData[0][3],
	toPredictData[0][4],
	toPredictData[0][5],
	toPredictData[0][6],
	toPredictData[0][7],
	toPredictData[0][8],
	toPredictData[0][9],
	toPredictData[0][10],
	toPredictData[0][11],
	toPredictData[0][12],
	toPredictData[0][13],
	toPredictData[0][14],
	toPredictData[0][15],
	toPredictData[0][16],
	toPredictData[0][17],
	toPredictData[0][18],
	toPredictData[0][19],
], 20);

Output:

  • This is the output at 60k interactions with errorThresh 0.005.
  • Always are descending or ascending.
  • ‘pre’ = close value taken from the forecast result.
  • ‘ori’ = original close value from the data.

{
 "0": { "day": 0, "ori": 302.73999, "pre": 281.6479115675968,"err": 6.97 },
 "1": { "day": 1, "ori": 292.920013, "pre": 280.9524207791296, "err": 4.09 },
 "2": { "day": 2, "ori": 289.029999, "pre": 280.2686673253774, "err": 3.03 },
 "3": { "day": 3, "ori": 266.170013, "pre": 279.0121085019256, "err": 4.83 },
 "4": { "day": 4, "ori": 285.339996, "pre": 277.6469256257541, "err": 2.7 },
 "5": { "day": 5, "ori": 275.429993, "pre": 276.35117074444383, "err": 0.33 },
 "6": { "day": 6, "ori": 248.22999600000003, "pre": 275.1655046414833, "err": 10.86 },
 "7": { "day": 7, "ori": 277.970001, "pre": 274.0908452116006, "err": 1.4 },
 "8": { "day": 8, "ori": 242.21000700000002, "pre": 273.12002506404633, "err": 12.77 },
 "9": { "day": 9, "ori": 252.86000100000004, "pre": 272.246150223522, "err": 7.67 },
 "10": { "day": 10, "ori": 246.669998, "pre": 271.46433827126106, "err": 10.06 },
 "11": { "day": 11, "ori": 244.779999, "pre": 270.77152304827797, "err": 10.63 },
 "12": { "day": 12, "ori": 229.240005, "pre": 270.16577111674127, "err": 17.87 },
 "13": { "day": 13, "ori": 224.36999499999996, "pre": 269.6458130477715, "err": 20.2 },
 "14": { "day": 14, "ori": 246.880005, "pre": 269.2104184718396, "err": 9.05 },
 "15": { "day": 15, "ori": 245.520004, "pre": 268.8578297181895, "err": 9.51 },
 "16": { "day": 16, "ori": 258.440002, "pre": 268.5851954542616, "err": 3.93 },
 "17": { "day": 17, "ori": 247.740005, "pre": 268.3882972702414, "err": 8.34 },
 "18": { "day": 18, "ori": 254.809998, "pre": 268.2612176745839, "err": 5.28 },
 "19": { "day": 19, "ori": 254.289993, "pre": 268.19596903018686, "err": 5.47 }
}

How important is this (1-5)?

3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
tyt34commented, Apr 12, 2020

It’s a LSTM

I just now read about this architecture. I think you right.

I right understand? training: 1 day before … 999 day before in input: open, close, high, low

in output: today and prediction value - close

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are Consecutive Numbers? | Printable Summary
Consecutive odd integers are odd numbers in their counting order · Note that an odd number will always be an integer.
Read more >
Descending consecutive integers : Quantitative - GMAT Club
I have a conceptual question. Whenever the GMAC mentions consecutive integers, does the sequence necessarily have to be ascending?
Read more >
Find if Array Contains 5 consecutive Numbers with Javascript
Both descending and ascending values count as consecutive (if that's not your case, then fiddle with the Math.abs() call). function consecutiveValuesCount(array) ...
Read more >
What are Consecutive Numbers? Definition, Formula, Examples
Consecutive numbers are numbers that follow each other continuously in the order from smallest to largest. Explore the consecutive even and odd numbers...
Read more >
What are Consecutive Numbers? Definition ... - Cuemath
Consecutive numbers are numbers that follow each other in order from the ... the set of even numbers from 2 to 12 and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found