Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LSTMTimeSeries

Long Short Term Memory Time Series with Tensorflow

implements

{BaseNeuralNetwork}

Hierarchy

Index

Constructors

constructor

  • new LSTMTimeSeries(options?: TensorScriptOptions, properties?: TensorScriptProperties): LSTMTimeSeries
  • Parameters

    • options: TensorScriptOptions = ...

      neural network configuration and tensorflow model hyperparameters

    • Optional properties: TensorScriptProperties

      extra instance properties

    Returns LSTMTimeSeries

Properties

compiled

compiled: boolean

createDataset

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

Type declaration

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

      • Rest ...args: any[]

      Returns NestedArray<number>

getInputShape

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

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

getTimeseriesDataSet

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

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

getTimeseriesShape

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

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

Optional layers

layers: TensorScriptSavedLayers

Optional loss

loss: number

model

model: any

reshape

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

Type declaration

    • (...args: any[]): any
    • Parameters

      • Rest ...args: any[]

      Returns any

settings

settings: TensorScriptOptions

tf

tf: any

tokenizer

tokenizer: any

trained

trained: boolean

type

type: string

Optional xShape

xShape: number[]

Optional yShape

yShape: number[]

Methods

calculate

  • calculate(x_matrix: Vector | Matrix | InputTextArray): any
  • Parameters

    • x_matrix: Vector | Matrix | InputTextArray

    Returns any

exportConfiguration

  • exportConfiguration(): TensorScriptContext

generateLayers

  • generateLayers(x_matrix: Matrix, y_matrix: Matrix, layers: TensorScriptSavedLayers): void
  • Adds dense layers to tensorflow classification model

    override

    Parameters

    • x_matrix: Matrix

      independent variables

    • y_matrix: Matrix

      dependent variables

    • layers: TensorScriptSavedLayers

      model dense layer parameters

    Returns void

importConfiguration

  • importConfiguration(configuration: TensorScriptContext): void
  • Parameters

    • configuration: TensorScriptContext

    Returns void

loadModel

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

predict

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

    • input_matrix: Vector | Matrix | InputTextArray
    • options: PredictionOptions = ...

    Returns Promise<any>

saveModel

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

train

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

    • x_timeseries: any
    • y_timeseries: any
    • layers: any
    • x_test: any
    • y_test: any

    Returns Promise<any>

Static createDataset

  • createDataset(dataset?: any[], look_back?: number): any[][]
  • 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

    • dataset: any[] = ...

      array of values

    • 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

Static getTimeseriesDataSet

  • getTimeseriesDataSet(timeseries: never[], look_back: any): { xShape: Shape; x_matrix: Vector | Matrix; yShape: Shape; y_matrix: any }
  • Returns data for predicting values

    Parameters

    • timeseries: never[]
    • look_back: any

    Returns { xShape: Shape; x_matrix: Vector | Matrix; yShape: Shape; y_matrix: any }

    • xShape: Shape
    • x_matrix: Vector | Matrix
    • yShape: Shape
    • y_matrix: any

Static getTimeseriesShape

  • getTimeseriesShape(x_timeseries: NestedArray<any>): Shape
  • 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

    • x_timeseries: NestedArray<any>

      dataset array of values

    Returns Shape

    returns proper timeseries forecasting shape

Static reshape

  • reshape(array: Vector, shape: Shape): Vector | Matrix
  • 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 Vector | Matrix

    returns a matrix with the defined shape