Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: Time Step Prediction #192

Closed
robertleeplummerjr opened this issue Apr 14, 2018 · 9 comments
Closed

New Feature: Time Step Prediction #192

robertleeplummerjr opened this issue Apr 14, 2018 · 9 comments
Assignees

Comments

@robertleeplummerjr
Copy link
Contributor

robertleeplummerjr commented Apr 14, 2018

A GIF or MEME to give some spice of the internet

What is the feature?

Prediction of trends. Stock market, weather predictions, trends, etc. This would be very similar to the existing recurrent net that will be deprecated, but will serve as a baseline for 2.0 GPU push. This will be included in v1 somewhere, as it is a simplification of the existing recurrent network.

How important is this (1-5)?

5

Usage:

import brain from 'brain.js';

const net = brain.recurrent.RNNTimeStep(options);
// or
const net = brain.recurrent.LSTMTimeStep(options);
// or
const net = brain.recurrent.GRUTimeStep(options);

net.train([
  [1,2,3,4,5],
  [5,4,3,2,1],
]);

net.run([1,2,3,4]) -> 5
net.run([5,4,3,2]) -> 1
@robertleeplummerjr
Copy link
Contributor Author

robertleeplummerjr commented Apr 14, 2018

It should be noted that this network type does not work by represented data. This type of neural network will work directly with the data you send in.

@RobertLowe
Copy link

RobertLowe commented Apr 14, 2018

@robertleeplummerjr another curiosity, how might one use this approach in aggregation with other time step layers, for example using 3 stocks in the same time period?

I'd like to select a time range of various time step data, I'll have a score applied time step event (say news polarity for example 0.0<->1.0 ), and predict from sets like that?

@robertleeplummerjr
Copy link
Contributor Author

The more context the net has, the better and I'm not sure that the net would know how to distinguish one from the other. I think it'd be best to train those nets separately. The up-side to that would be each net would be smart enough to tracks its progress, but it would not do well at adjusting based off context of other financials. Example: gold goes up, dollar goes down.

If some sort of non-generalized approach was needed I suppose a custom solution could be built.

The LSTM version (which would be my recommendation to use) uses simple math to achieve its equation: https://github.com/BrainJS/brain.js/blob/develop/src/recurrent/lstm.js#L48 so by modifying that, we may be able to achieve the context you are wishing for.

@robertleeplummerjr robertleeplummerjr changed the title New Feature: Time Series Prediction New Feature: Time Step Prediction Apr 15, 2018
@robertleeplummerjr
Copy link
Contributor Author

robertleeplummerjr commented Apr 15, 2018

I thought about this and it hit me this morning, this is already somewhat supported. This is how:

The time step prediction currently only accepts a single value at a time, also it only outputs a single value at a time. By default the network is setup as:

const net = new brain.recurrent.LSTMTimeStep({
  inputSize: 1,
  hiddenSizes: [20, 20],
  outputSize: 1
});

The inputSize represents the single time-step. So, simply make it larger, done. This isn't unit tested, I'll if I can get it supported though.

As for v2, I imagine brain.recurrent.LSTMTimeStep will likely shorten to something like:

import { TimeStep } from 'brain.js';
const net = new TimeStep();

This way the default layer will simply be a runner for whatever layers we want, in this case just rnn, lstm, or gru.

@RobertLowe
Copy link

Awesome, keep me posted! Thanks! 👍

stroke-of-genius

@robertleeplummerjr
Copy link
Contributor Author

Support added: d8f9170

@robertleeplummerjr
Copy link
Contributor Author

also tested ^

@RobertLowe
Copy link

Thanks! And thanks for the tests, they make it really clear! 👍

@robertleeplummerjr
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants