neural network configuration and tensorflow model hyperparameters
Optional properties: TensorScriptPropertiesextra instance properties
Rest ...args: any[]Rest ...args: any[]Rest ...args: any[]Rest ...args: any[]Rest ...args: any[]Rest ...args: any[]Optional layersOptional lossRest ...args: any[]Rest ...args: any[]Optional xOptional yAdds dense layers to tensorflow classification model
independent variables
dependent variables
model dense layer parameters
Loads a saved tensoflow / keras model, this is an alias for
tensorflow model
https://www.tensorflow.org/js/guide/save_load#loading_a_tfmodel
tensorflow load model options
Returns prediction values from tensorflow model
predicted model values
new test independent variables
saves a tensorflow model, this is an alias for
tensorflow model
https://www.tensorflow.org/js/guide/save_load#save_a_tfmodel
tensorflow save model options
Static createCreates dataset data
const ds = [
[10, 20, 30, 40, 50, 60, 70, 80, 90,],
[11, 21, 31, 41, 51, 61, 71, 81, 91,],
[12, 22, 32, 42, 52, 62, 72, 82, 92,],
[13, 23, 33, 43, 53, 63, 73, 83, 93,],
[14, 24, 34, 44, 54, 64, 74, 84, 94,],
[15, 25, 35, 45, 55, 65, 75, 85, 95,],
[16, 26, 36, 46, 56, 66, 76, 86, 96,],
[17, 27, 37, 47, 57, 67, 77, 87, 97,],
[18, 28, 38, 48, 58, 68, 78, 88, 98,],
[19, 29, 39, 49, 59, 69, 79, 89, 99,],
];
LSTMMultivariateTimeSeries.createDataset(ds,1) // =>
// [
// [
// [ 20, 30, 40, 50, 60, 70, 80, 90 ],
// [ 21, 31, 41, 51, 61, 71, 81, 91 ],
// [ 22, 32, 42, 52, 62, 72, 82, 92 ],
// [ 23, 33, 43, 53, 63, 73, 83, 93 ],
// [ 24, 34, 44, 54, 64, 74, 84, 94 ],
// [ 25, 35, 45, 55, 65, 75, 85, 95 ],
// [ 26, 36, 46, 56, 66, 76, 86, 96 ],
// [ 27, 37, 47, 57, 67, 77, 87, 97 ],
// [ 28, 38, 48, 58, 68, 78, 88, 98 ]
// ], //x_matrix
// [ 11, 12, 13, 14, 15, 16, 17, 18, 19 ], //y_matrix
// 8 //features
// ]
returns x matrix and y matrix for model trainning
array of values
number of values in each feature
Static dropDrops columns by array index
const data = [ [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 11, 21, 31, 41, 51, 61, 71, 81, 91 ],
[ 11, 21, 31, 41, 51, 61, 71, 81, 91, 12, 22, 32, 42, 52, 62, 72, 82, 92 ],
[ 12, 22, 32, 42, 52, 62, 72, 82, 92, 13, 23, 33, 43, 53, 63, 73, 83, 93 ],
[ 13, 23, 33, 43, 53, 63, 73, 83, 93, 14, 24, 34, 44, 54, 64, 74, 84, 94 ],
[ 14, 24, 34, 44, 54, 64, 74, 84, 94, 15, 25, 35, 45, 55, 65, 75, 85, 95 ],
[ 15, 25, 35, 45, 55, 65, 75, 85, 95, 16, 26, 36, 46, 56, 66, 76, 86, 96 ],
[ 16, 26, 36, 46, 56, 66, 76, 86, 96, 17, 27, 37, 47, 57, 67, 77, 87, 97 ],
[ 17, 27, 37, 47, 57, 67, 77, 87, 97, 18, 28, 38, 48, 58, 68, 78, 88, 98 ],
[ 18, 28, 38, 48, 58, 68, 78, 88, 98, 19, 29, 39, 49, 59, 69, 79, 89, 99 ] ];
const n_in = 1; //lookbacks
const n_out = 1;
const dropColumns = getDropableColumns(8, n_in, n_out); // =>[ 10, 11, 12, 13, 14, 15, 16, 17 ]
const newdata = drop(data,dropColumns); //=> [
// [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 11 ],
// [ 11, 21, 31, 41, 51, 61, 71, 81, 91, 12 ],
// [ 12, 22, 32, 42, 52, 62, 72, 82, 92, 13 ],
// [ 13, 23, 33, 43, 53, 63, 73, 83, 93, 14 ],
// [ 14, 24, 34, 44, 54, 64, 74, 84, 94, 15 ],
// [ 15, 25, 35, 45, 55, 65, 75, 85, 95, 16 ],
// [ 16, 26, 36, 46, 56, 66, 76, 86, 96, 17 ],
// [ 17, 27, 37, 47, 57, 67, 77, 87, 97, 18 ],
// [ 18, 28, 38, 48, 58, 68, 78, 88, 98, 19 ]
//]
matrix with dropped columns
data set to drop columns
array of column indexes
Static getCalculates which columns to drop by index
support multiple iterations in the future, also only one output variable supported in column features * lookbacks -1
const ds = [
[10, 20, 30, 40, 50, 60, 70, 80, 90,],
[11, 21, 31, 41, 51, 61, 71, 81, 91,],
[12, 22, 32, 42, 52, 62, 72, 82, 92,],
[13, 23, 33, 43, 53, 63, 73, 83, 93,],
[14, 24, 34, 44, 54, 64, 74, 84, 94,],
[15, 25, 35, 45, 55, 65, 75, 85, 95,],
[16, 26, 36, 46, 56, 66, 76, 86, 96,],
[17, 27, 37, 47, 57, 67, 77, 87, 97,],
[18, 28, 38, 48, 58, 68, 78, 88, 98,],
[19, 29, 39, 49, 59, 69, 79, 89, 99,],
];
const n_in = 1; //lookbacks
const n_out = 1;
const dropped = getDropableColumns(8, n_in, n_out); //=> [ 10, 11, 12, 13, 14, 15, 16, 17 ]
array indexes to drop
number of independent variables
look backs
future iterations (currently only 1 supported)
Static getStatic getReturns data for predicting values
Static getReshape input to be [samples, time steps, features]
@override
LSTMTimeSeries.getTimeseriesShape([
[ [ 1 ], [ 2 ], [ 3 ] ],
[ [ 2 ], [ 3 ], [ 4 ] ],
[ [ 3 ], [ 4 ], [ 5 ] ],
[ [ 4 ], [ 5 ], [ 6 ] ],
[ [ 5 ], [ 6 ], [ 7 ] ],
[ [ 6 ], [ 7 ], [ 8 ] ],
]) //=> [6, 1, 3,]
returns proper timeseries forecasting shape
dataset array of values
Static reshapeReshapes an array
const array = [ 0, 1, 1, 0, ];
const shape = [2,2];
TensorScriptModelInterface.reshape(array,shape) // =>
[
[ 0, 1, ],
[ 1, 0, ],
];
returns a matrix with the defined shape
input array
shape array
Static seriesConverts data set to supervised labels for forecasting, the first column must be the dependent variable
const ds = [
[10, 20, 30, 40, 50, 60, 70, 80, 90,],
[11, 21, 31, 41, 51, 61, 71, 81, 91,],
[12, 22, 32, 42, 52, 62, 72, 82, 92,],
[13, 23, 33, 43, 53, 63, 73, 83, 93,],
[14, 24, 34, 44, 54, 64, 74, 84, 94,],
[15, 25, 35, 45, 55, 65, 75, 85, 95,],
[16, 26, 36, 46, 56, 66, 76, 86, 96,],
[17, 27, 37, 47, 57, 67, 77, 87, 97,],
[18, 28, 38, 48, 58, 68, 78, 88, 98,],
[19, 29, 39, 49, 59, 69, 79, 89, 99,],
];
const n_in = 1; //lookbacks
const n_out = 1;
const series = seriesToSupervised(ds, n_in, n_out); //=> [
// [ 10, 20, 30, 40, 50, 60, 70, 80, 90, 11, 21, 31, 41, 51, 61, 71, 81, 91 ],
// [ 11, 21, 31, 41, 51, 61, 71, 81, 91, 12, 22, 32, 42, 52, 62, 72, 82, 92 ],
// [ 12, 22, 32, 42, 52, 62, 72, 82, 92, 13, 23, 33, 43, 53, 63, 73, 83, 93 ],
// [ 13, 23, 33, 43, 53, 63, 73, 83, 93, 14, 24, 34, 44, 54, 64, 74, 84, 94 ],
// [ 14, 24, 34, 44, 54, 64, 74, 84, 94, 15, 25, 35, 45, 55, 65, 75, 85, 95 ],
// [ 15, 25, 35, 45, 55, 65, 75, 85, 95, 16, 26, 36, 46, 56, 66, 76, 86, 96 ],
// [ 16, 26, 36, 46, 56, 66, 76, 86, 96, 17, 27, 37, 47, 57, 67, 77, 87, 97 ],
// [ 17, 27, 37, 47, 57, 67, 77, 87, 97, 18, 28, 38, 48, 58, 68, 78, 88, 98 ],
// [ 18, 28, 38, 48, 58, 68, 78, 88, 98, 19, 29, 39, 49, 59, 69, 79, 89, 99 ]
//];
support multiple future iterations
multivariate dataset for time series
data set
look backs
future iterations (only 1 supported)
Long Short Term Memory Multivariate Time Series with Tensorflow