Class LSTMTimeSeries

Long Short Term Memory Time Series with Tensorflow

Implements

Hierarchy

Constructors

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

  • Predicts new dependent variables

    Returns

    returns tensorflow prediction

    Parameters

    • x_matrix: Matrix | Vector | InputTextArray

    Returns any

  • Adds dense layers to tensorflow classification model

    Parameters

    • this: TensorScriptLSTMModelContext
    • x_matrix: Matrix

      independent variables

    • y_matrix: Matrix

      dependent variables

    • layers: TensorScriptSavedLayers

      model dense layer parameters

    Returns void

  • Returns prediction values from tensorflow model

    Returns

    predicted model values

    Parameters

    • input_matrix: Matrix | Vector | InputTextArray

      new test independent variables

    • options: PredictionOptions = {}

    Returns Promise<any>

  • Asynchronously trains tensorflow model

    Returns

    returns trained tensorflow model

    Parameters

    • x_timeseries: any

      independent variables

    • y_timeseries: any

      dependent variables

    • layers: any

      array of model dense layer parameters

    • x_test: any
    • y_test: any

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

    Returns

    returns x matrix and y matrix for model trainning

    Parameters

    • dataset: never[] = []

      array of values

    • look_back: number = 1

      number of values in each feature

    Returns any[][]

  • Returns the shape of an input matrix

    Function

    Example

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

    See

    Returns

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

    Parameters

    • matrix: any = []

      input matrix

    Returns Shape

  • Returns data for predicting values

    Parameters

    • this: TensorScriptLSTMModelContext
    • timeseries: undefined | never[]
    • look_back: any

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

    • xShape: Shape
    • x_matrix: Matrix | Vector
    • yShape: Shape
    • y_matrix: any[]
  • 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,]

    Returns

    returns proper timeseries forecasting shape

    Parameters

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

      dataset array of values

    Returns Shape

  • Reshapes an array

    Function

    Example

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

    Returns

    returns a matrix with the defined shape

    Parameters

    • array: Vector

      input array

    • shape: Shape

      shape array

    Returns Matrix | Vector