    import {LSTMTimeSeries} from 'tensorscript-node/lib/lstm_time_series.mjs'

public class | source

# LSTMTimeSeries

#### Extends:

lib/deep_learning.js~BaseNeuralNetwork → LSTMTimeSeries

#### Direct Subclass:

LSTMMultivariateTimeSeries

#### Implements:

- BaseNeuralNetwork

Long Short Term Memory Time Series with Tensorflow

#### Test:

- LSTMTimeSeries

## Static Method Summary

Static Public Methods
public static | createDataset(dataset: Array<Array<number>, look_back: Number): [Array<Array<number>>,Array<number>] Creates dataset data |
public static | getTimeseriesDataSet(timeseries: *, look_back: *) Returns data for predicting values |
public static | getTimeseriesShape(x_timeseries: Array<Array<number>): Array<Array<number>> Reshape input to be [samples, time steps, features] |

## Constructor Summary

Public Constructor
public | constructor(options: {layers: Array<Object>, compile: Object, fit: Object}, properties: *) |

## Member Summary

Public Members
public | createDataset |
public | getTimeseriesDataSet |
public | getTimeseriesShape |
public | layers |
public | model |
public | xShape |
public | yShape |

## Method Summary

Public Methods
public | calculate() |
public | generateLayers(x_matrix: Array<Array<number>>, y_matrix: Array<Array<number>>, layers: Array<Object>, x_test: Array<Array<number>>, y_test: Array<Array<number>>) Adds dense layers to tensorflow classification model |
public | async predict() |
public | async train() |

## Static Public Methods

### public static createDataset(dataset: Array<Array<number>, look_back: Number): [Array<Array<number>>,Array<number>] source

Creates dataset data

#### Params:

Name | Type | Attribute | Description
dataset | Array<Array<number> |  | array of values
look_back | Number |  | number of values in each feature

#### Return:

[Array<Array<number>>,Array<number>] | returns x matrix and y matrix for model trainning

#### Example:

    LSTMTimeSeries.createDataset([ [ 1, ], [ 2, ], [ 3, ], [ 4, ], [ 5, ], [ 6, ], [ 7, ], [ 8, ], [ 9, ], [ 10, ], ], 3) // =>
    //  [
    //    [
    //      [ [ 1 ], [ 2 ], [ 3 ] ],
    //      [ [ 2 ], [ 3 ], [ 4 ] ],
    //      [ [ 3 ], [ 4 ], [ 5 ] ],
    //      [ [ 4 ], [ 5 ], [ 6 ] ],
    //      [ [ 5 ], [ 6 ], [ 7 ] ],
    //      [ [ 6 ], [ 7 ], [ 8 ] ],
    //   ], //x_matrix
    //   [ [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ] ] //y_matrix
    // ]

### public static getTimeseriesDataSet(timeseries: *, look_back: *) source

Returns data for predicting values

#### Params:

Name | Type | Attribute | Description
timeseries | * |  |
look_back | * |  |

### public static getTimeseriesShape(x_timeseries: Array<Array<number>): Array<Array<number>> source

Reshape input to be [samples, time steps, features]

#### Params:

Name | Type | Attribute | Description
x_timeseries | Array<Array<number> |  | dataset array of values

#### Return:

Array<Array<number>> | returns proper timeseries forecasting shape

#### Example:

    LSTMTimeSeries.getTimeseriesShape([
    [ [ 1 ], [ 2 ], [ 3 ] ],
    [ [ 2 ], [ 3 ], [ 4 ] ],
    [ [ 3 ], [ 4 ], [ 5 ] ],
    [ [ 4 ], [ 5 ], [ 6 ] ],
    [ [ 5 ], [ 6 ], [ 7 ] ],
    [ [ 6 ], [ 7 ], [ 8 ] ],
    ]) //=> [6, 1, 3,]

## Public Constructors

### public constructor(options: {layers: Array<Object>, compile: Object, fit: Object}, properties: *) source

#### Params:

Name | Type | Attribute | Description
options | {layers: Array<Object>, compile: Object, fit: Object} |  | neural network configuration and tensorflow model hyperparameters
properties | * |  | extra instance properties

#### Test:

- LSTMTimeSeries constructor

## Public Members

### public createDataset source

#### Test:

- LSTMTimeSeries static createDataset

### public getTimeseriesDataSet source

#### Test:

- LSTMTimeSeries static getTimeseriesDataSet

### public getTimeseriesShape source

#### Test:

- LSTMTimeSeries static getTimeseriesShape

### public layers source

### public model source

### public xShape source

### public yShape source

## Public Methods

### public calculate() source

### public generateLayers(x_matrix: Array<Array<number>>, y_matrix: Array<Array<number>>, layers: Array<Object>, x_test: Array<Array<number>>, y_test: Array<Array<number>>) source

Adds dense layers to tensorflow classification model

#### Params:

Name | Type | Attribute | Description
x_matrix | Array<Array<number>> |  | independent variables
y_matrix | Array<Array<number>> |  | dependent variables
layers | Array<Object> |  | model dense layer parameters
x_test | Array<Array<number>> |  | validation data independent variables
y_test | Array<Array<number>> |  | validation data dependent variables

#### Test:

- LSTMTimeSeries generateLayers

### public async predict() source

#### Test:

- LSTMMultivariateTimeSeries async predict
- LSTMTimeSeries async predict

### public async train() source

#### Test:

- LSTMTimeSeries async train