    import {TensorScriptModelInterface} from 'tensorscript-node/lib/model_interface.mjs'

public class | source

# TensorScriptModelInterface

#### Direct Implemented:

- BaseNeuralNetwork

Base class for tensorscript models

#### Test:

- TensorScriptModelInterface

## Static Method Summary

Static Public Methods
public static | getInputShape(matrix: Array<Array<number>>): Array<number> Returns the shape of an input matrix |
public static | reshape(array: Array<number>, shape: Array<number>): Array<Array<number>> Reshapes an array |

## Constructor Summary

Public Constructor
public | constructor(options: Object, customTF: Object, properties: *) |

## Member Summary

Public Members
public | getInputShape: Function |
public | model: Object |
public | reshape: Function |
public | settings: Object |
public | tf: Object |

## Method Summary

Public Methods
public abstract | calculate(matrix: Array<Array<number>>|Array<number>): {data: Promise} Predicts new dependent variables |
public | async loadModel(options: Object): Object Loads a saved tensoflow / keras model |
public | async predict(input_matrix: Array<Array<number>>|Array<number>): Array<number>|Array<Array<number>> Returns prediction values from tensorflow model |
public abstract | train(x_matrix: Array<Array<number>>, y_matrix: Array<Array<number>>): Object Asynchronously trains tensorflow model, must be implemented by tensorscript class |

## Static Public Methods

### public static getInputShape(matrix: Array<Array<number>>): Array<number> source

Returns the shape of an input matrix

#### Params:

Name | Type | Attribute | Description
matrix | Array<Array<number>> |  | input matrix

#### Return:

Array<number> | returns the shape of a matrix (e.g. [2,2])

#### Example:

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

#### See:

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

### public static reshape(array: Array<number>, shape: Array<number>): Array<Array<number>> source

Reshapes an array

#### Params:

Name | Type | Attribute | Description
array | Array<number> |  | input array
shape | Array<number> |  | shape array

#### Return:

Array<Array<number>> | returns a matrix with the defined shape

#### Example:

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

## Public Constructors

### public constructor(options: Object, customTF: Object, properties: *) source

#### Params:

Name | Type | Attribute | Description
options | Object |  | tensorflow model hyperparameters
customTF | Object |  | custom, overridale tensorflow / tensorflow-node / tensorflow-node-gpu
properties | * |  | extra instance properties

#### Test:

- TensorScriptModelInterface constructor

## Public Members

### public getInputShape: Function source

#### Test:

- TensorScriptModelInterface getInputShape

### public model: Object source

### public reshape: Function source

#### Test:

- TensorScriptModelInterface reshape

### public settings: Object source

### public tf: Object source

## Public Methods

### public abstract calculate(matrix: Array<Array<number>>|Array<number>): {data: Promise} source

Predicts new dependent variables

#### Params:

Name | Type | Attribute | Description
matrix | Array<Array<number>>|Array<number> |  | new test independent variables

#### Return:

{data: Promise} | returns tensorflow prediction

#### Test:

- TensorScriptModelInterface calculate

### public async loadModel(options: Object): Object source

Loads a saved tensoflow / keras model

#### Params:

Name | Type | Attribute | Description
options | Object |  | tensorflow load model options

#### Return:

Object | tensorflow model

#### Test:

- TensorScriptModelInterface loadModel

### public async predict(input_matrix: Array<Array<number>>|Array<number>): Array<number>|Array<Array<number>> source

Returns prediction values from tensorflow model

#### Params:

Name | Type | Attribute | Description
input_matrix | Array<Array<number>>|Array<number> |  | new test independent variables
options.json | Boolean | optional default: true | return object instead of typed array
options.probability | Boolean | optional default: true | return real values instead of integers

#### Return:

Array<number>|Array<Array<number>> | predicted model values

#### Test:

- TensorScriptModelInterface predict

### public abstract train(x_matrix: Array<Array<number>>, y_matrix: Array<Array<number>>): Object source

Asynchronously trains tensorflow model, must be implemented by tensorscript class

#### Params:

Name | Type | Attribute | Description
x_matrix | Array<Array<number>> |  | independent variables
y_matrix | Array<Array<number>> |  | dependent variables

#### Return:

Object | returns trained tensorflow model

#### Test:

- TensorScriptModelInterface train