Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LSTMTimeSeries

Long Short Term Memory Time Series with Tensorflow

implements

{BaseNeuralNetwork}

Hierarchy

Index

Constructors

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

Properties

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

Type declaration

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

      • Rest ...args: any[]

      Returns NestedArray<number>

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

Type declaration

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

      • Rest ...args: any[]

      Returns any

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

Type declaration

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

      • Rest ...args: any[]

      Returns any

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

Type declaration

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

      • Rest ...args: any[]

      Returns any

layers?: TensorScriptSavedLayers
loss?: number
model: any
reshape: (...args: any[]) => any

Type declaration

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

      • Rest ...args: any[]

      Returns any

settings: TensorScriptOptions
tf: any
tokenizer: any
trained: boolean
type: string
xShape?: number[]
yShape?: number[]

Methods

  • calculate(x_matrix: Vector | Matrix | InputTextArray): any
  • exportConfiguration(): TensorScriptContext
  • generateLayers(this: TensorScriptLSTMModelContext, x_matrix: Matrix, y_matrix: Matrix, layers: TensorScriptSavedLayers): void
  • 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(configuration: TensorScriptContext): void
  • loadModel(options: string): Promise<any>
  • predict(input_matrix: Vector | Matrix | InputTextArray, options?: PredictionOptions): Promise<any>
  • Returns prediction values from tensorflow model

    Parameters

    • input_matrix: Vector | Matrix | InputTextArray
    • options: PredictionOptions = {}

    Returns Promise<any>

    predicted model values

  • saveModel(options: string): Promise<any>
  • train(x_timeseries: any, y_timeseries: any, layers: any, x_test: any, y_test: any): Promise<any>
  • Asynchronously trains tensorflow model

    Parameters

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

    Returns Promise<any>

    returns trained tensorflow model

  • createDataset(dataset?: never[], 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: never[] = []

      array of values

    • look_back: number = 1

      number of values in each feature

    Returns any[][]

    returns x matrix and y matrix for model trainning

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

    Parameters

    • this: TensorScriptLSTMModelContext
    • timeseries: undefined | 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[]
  • getTimeseriesShape(this: TimeSeriesShapeContext, x_timeseries: undefined | 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

    • this: TimeSeriesShapeContext
    • x_timeseries: undefined | NestedArray<any>

      dataset array of values

    Returns Shape

    returns proper timeseries forecasting shape

  • 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