Long Short Term Memory Time Series with Tensorflow

implements

  {BaseNeuralNetwork}

### Hierarchy

- BaseNeuralNetwork
  - LSTMTimeSeries
    - LSTMMultivariateTimeSeries

## Index

### Constructors

- constructor

### Properties

- compiled
- createDataset
- getInputShape
- getTimeseriesDataSet
- getTimeseriesShape
- layers
- model
- reshape
- settings
- tf
- tokenizer
- trained
- type
- xShape
- yShape

### Methods

- calculate
- exportConfiguration
- generateLayers
- importConfiguration
- loadModel
- predict
- saveModel
- train
- createDataset
- getInputShape
- getTimeseriesDataSet
- getTimeseriesShape
- reshape

## Constructors

### constructor

- new LSTMTimeSeries(options?: TensorScriptOptions, properties?: TensorScriptProperties): LSTMTimeSeries

- Overrides BaseNeuralNetwork.constructor

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:102

  #### Parameters

  - ##### Default value options: TensorScriptOptions = {}

    neural network configuration and tensorflow model hyperparameters

  - ##### Optional properties: TensorScriptProperties

    extra instance properties

  #### Returns LSTMTimeSeries

## Properties

### compiled

compiled: boolean

Inherited from TensorScriptModelInterface.compiled

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:214

### createDataset

createDataset: (...args: any[]) => NestedArray<number>

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:100

#### Type declaration

- - (...args: any[]): NestedArray<number>

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns NestedArray<number>

### getInputShape

getInputShape: (...args: any[]) => any

Inherited from TensorScriptModelInterface.getInputShape

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:216

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### getTimeseriesDataSet

getTimeseriesDataSet: (...args: any[]) => any

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:102

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### getTimeseriesShape

getTimeseriesShape: (...args: any[]) => any

Overrides TensorScriptModelInterface.getTimeseriesShape

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:101

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### Optional layers

layers: TensorScriptSavedLayers

Overrides TensorScriptModelInterface.layers

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:16

### model

model: any

Inherited from TensorScriptModelInterface.model

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:210

### reshape

reshape: (...args: any[]) => any

Inherited from TensorScriptModelInterface.reshape

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:215

#### Type declaration

- - (...args: any[]): any

  - #### Parameters

    - ##### Rest ...args: any[]

    #### Returns any

### settings

settings: TensorScriptOptions

Inherited from TensorScriptModelInterface.settings

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:209

### tf

tf: any

Inherited from TensorScriptModelInterface.tf

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:212

### tokenizer

tokenizer: any

Inherited from TensorScriptModelInterface.tokenizer

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:211

### trained

trained: boolean

Inherited from TensorScriptModelInterface.trained

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:213

### type

type: string

Inherited from TensorScriptModelInterface.type

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:208

### Optional xShape

xShape: number[]

Inherited from TensorScriptModelInterface.xShape

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:217

### Optional yShape

yShape: number[]

Inherited from TensorScriptModelInterface.yShape

- Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:218

## Methods

### calculate

- calculate(x_matrix: Matrix | Vector | InputTextArray): any

- Overrides BaseNeuralNetwork.calculate

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:240

  #### Parameters

  - ##### x_matrix: Matrix | Vector | InputTextArray

  #### Returns any

### exportConfiguration

- exportConfiguration(): TensorScriptContext

- Inherited from TensorScriptModelInterface.exportConfiguration

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:346

  #### Returns TensorScriptContext

### generateLayers

- generateLayers(this: TensorScriptLSTMModelContext, x_matrix: Matrix, y_matrix: Matrix, layers: TensorScriptSavedLayers): void

- Overrides BaseNeuralNetwork.generateLayers

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:144

  Adds dense layers to tensorflow classification model

  override

  #### Parameters

  - ##### this: TensorScriptLSTMModelContext

  - ##### x_matrix: Matrix

    independent variables

  - ##### y_matrix: Matrix

    dependent variables

  - ##### layers: TensorScriptSavedLayers

    model dense layer parameters

  #### Returns void

### importConfiguration

- importConfiguration(configuration: TensorScriptContext): void

- Inherited from TensorScriptModelInterface.importConfiguration

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:357

  #### Parameters

  - ##### configuration: TensorScriptContext

  #### Returns void

### loadModel

- loadModel(options: string): Promise<any>

- Inherited from TensorScriptModelInterface.loadModel

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:396

  Loads a saved tensoflow / keras model, this is an alias for

  see

    https://www.tensorflow.org/js/guide/save_load#loading_a_tfmodel

  #### Parameters

  - ##### options: string

    tensorflow load model options

  #### Returns Promise<any>

  tensorflow model

### predict

- predict(input_matrix: Matrix | Vector | InputTextArray, options?: PredictionOptions): Promise<any>

- Overrides TensorScriptModelInterface.predict

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:246

  #### Parameters

  - ##### input_matrix: Matrix | Vector | InputTextArray

  - ##### Default value options: PredictionOptions = {}

  #### Returns Promise<any>

### saveModel

- saveModel(options: string): Promise<any>

- Inherited from TensorScriptModelInterface.saveModel

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:409

  saves a tensorflow model, this is an alias for

  see

    https://www.tensorflow.org/js/guide/save_load#save_a_tfmodel

  #### Parameters

  - ##### options: string

    tensorflow save model options

  #### Returns Promise<any>

  tensorflow model

### train

- train(x_timeseries: any, y_timeseries: any, layers: any, x_test: any, y_test: any): Promise<any>

- Overrides BaseNeuralNetwork.train

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:199

  #### Parameters

  - ##### x_timeseries: any

  - ##### y_timeseries: any

  - ##### layers: any

  - ##### x_test: any

  - ##### y_test: any

  #### Returns Promise<any>

### Static createDataset

- createDataset(dataset?: never[], look_back?: number): any[][]

- - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:39

  Creates dataset data

  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 // ]

  #### Parameters

  - ##### Default value dataset: never[] = []

    array of values

  - ##### Default value look_back: number = 1

    number of values in each feature

  #### Returns any[][]

  returns x matrix and y matrix for model trainning

### Static getInputShape

- getInputShape(matrix?: any): Shape

- Inherited from TensorScriptModelInterface.getInputShape

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:327

  Returns the shape of an input matrix

  function
  example

    const input = [ [ 0, 1, ], [ 1, 0, ], ]; TensorScriptModelInterface.getInputShape(input) // => [2,2]

  see

    {https://stackoverflow.com/questions/10237615/get-size-of-dimensions-in-array}

  #### Parameters

  - ##### Default value matrix: any = []

    input matrix

  #### Returns Shape

  returns the shape of a matrix (e.g. [2,2])

### Static getTimeseriesDataSet

- getTimeseriesDataSet(this: TensorScriptLSTMModelContext, timeseries: never[] | undefined, look_back: any): { xShape: number | number[]; x_matrix: number[][] | number[]; yShape: number | number[]; y_matrix: any[] }

- - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:83

  Returns data for predicting values

  #### Parameters

  - ##### this: TensorScriptLSTMModelContext

  - ##### timeseries: never[] | undefined

  - ##### look_back: any

  #### Returns { xShape: number | number[]; x_matrix: number[][] | number[]; yShape: number | number[]; y_matrix: any[] }

  - ##### xShape: number | number[]

  - ##### x_matrix: number[][] | number[]

  - ##### yShape: number | number[]

  - ##### y_matrix: any[]

### Static getTimeseriesShape

- getTimeseriesShape(this: TimeSeriesShapeContext, x_timeseries: NestedArray<any> | undefined): Shape

- - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/lstm_time_series.ts:64

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

  example

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

  #### Parameters

  - ##### this: TimeSeriesShapeContext

  - ##### x_timeseries: NestedArray<any> | undefined

    dataset array of values

  #### Returns Shape

  returns proper timeseries forecasting shape

### Static reshape

- reshape(array: Vector, shape: Shape): Matrix | Vector

- Inherited from TensorScriptModelInterface.reshape

  - Defined in Users/yawjosephetse/Developer/github/repetere/modelx-model/src/model_interface.ts:262

  Reshapes an array

  function
  example

    const array = [ 0, 1, 1, 0, ]; const shape = [2,2]; TensorScriptModelInterface.reshape(array,shape) // => [ [ 0, 1, ], [ 1, 0, ], ];

  #### Parameters

  - ##### array: Vector

    input array

  - ##### shape: Shape

    shape array

  #### Returns Matrix | Vector

  returns a matrix with the defined shape