TensorScript - Machine Learning and Neural Networks with Tensorflow
Introduction
This library is a compilation of model building modules with a consistent API for quickly implementing Tensorflow at edge(browser) or any JavaScript environment (Node JS / GPU).
Read the manual
List of Tensorflow models
Classification
- Deep Learning Classification:
DeepLearningClassification
- Logistic Regression:
LogisticRegression
Regression
- Deep Learning Regression:
DeepLearningRegression
- Multivariate Linear Regression:
MultipleLinearRegression
Artificial neural networks (ANN)
- Multi-Layered Perceptrons:
BaseNeuralNetwork
LSTM Time Series
- Long Short Term Memory Time Series:
LSTMTimeSeries
- Long Short Term Memory Multivariate Time Series:
LSTMMultivariateTimeSeries
Basic Usage
TensorScript is and ECMA Script module designed to be used in an ES2015+
environment, if you need compiled modules for older versions of node use the compiled modules in the bundle folder.
Please read more on tensorflow configuration options, specifying epochs, and using custom layers in configuration.
Regression Examples
;; { const independentVariables = 'sqft' 'bedrooms'; const dependentVariables = 'price' ; const housingdataCSV = await mscsv; const DataSet = housingdataCSV; const x_matrix = DataSet; const y_matrix = DataSet; const MLR = ; await MLR; const DLR = ; await DLR; //1600 sqft, 3 bedrooms await MLR; //=>[293081.46] await DLR; //=>[293081.46]};
Classification Examples
;; { const independentVariables = 'sepal_length_cm' 'sepal_width_cm' 'petal_length_cm' 'petal_width_cm' ; const dependentVariables = 'plant_Iris-setosa' 'plant_Iris-versicolor' 'plant_Iris-virginica' ; const housingdataCSV = await mscsv; const DataSet = housingdataCSV; const x_matrix = DataSet; const y_matrix = DataSet; const nnClassification = ; await nnClassification; const input_x = 51 35 14 02 63 33 60 25 56 30 45 15 50 32 12 02 45 23 13 03 ; const predictions = await nnClassification; const answers = await nnClassification; /* predictions = [ [ 0.989512026309967, 0.010471616871654987, 0.00001649192017794121, ], [ 0.0000016141033256644732, 0.054614484310150146, 0.9453839063644409, ], [ 0.001930746017023921, 0.6456733345985413, 0.3523959517478943, ], [ 0.9875779747962952, 0.01239941269159317, 0.00002274810685776174, ], [ 0.9545140862464905, 0.04520365223288536, 0.0002823179238475859, ], ]; answers = [ [ 1, 0, 0, ], //setosa [ 0, 0, 1, ], //virginica [ 0, 1, 0, ], //versicolor [ 1, 0, 0, ], //setosa [ 1, 0, 0, ], //setosa ]; */};
;; { const independentVariables = 'Age' 'EstimatedSalary' ; const dependentVariables = 'Purchased' ; const housingdataCSV = await mscsv; const DataSet = housingdataCSV; const x_matrix = DataSet; const y_matrix = DataSet; const LR = ; await LR; const input_x = -0062482849427819266 030083326827486173 //0 07960601198093905 -11069168538010206 //1 07960601198093905 012486450301537644 //0 04144854668150751 -049102617539282206 //0 03190918035664962 05061301610775946 //1 ; const predictions = await LR; // => [ [ 0 ], [ 0 ], [ 1 ], [ 0 ], [ 1 ] ];};
Time Series Example
;; { const dependentVariables = 'Passengers' ; const airlineCSV = await mscsv; const DataSet = airlineCSV; const x_matrix = DataSet; const TS = ; await TS; const forecastData = TS await TS; //=>[200,300,400]};
Testing
$ npm i$ npm test
Contributing
Fork, write tests and create a pull request!
Misc
As of Node 8, ES modules are still used behind a flag, when running natively as an ES module
$ node --experimental-modules manual/examples/ex_regression-boston.mjs# Also there are native bindings that require Python 2.x, make sure if you're using Anaconda, you build with your Python 2.x bin $ npm i --python=/usr/bin/python
### Special Thanks
License
MIT