An end-to-end example of TensorFlow.js code flow for the data classification task. This app is built with React, but the same code can be reused with any JS toolkit/framework.

I thought it would be helpful to create a plain simple React application with a well-structured TensorFlow.js code logic for data classification. The main idea is that someone who would like to code logic and build a model with TensorFlow.js, should be able to copy-paste from my sample app easily. For this reason, I’m using a simple dataset, but the code structure contains all the logic to handle a complex dataset too.

The data I’m using is visualized in the picture below. There are 3 groups of data points — red, blue, and green. Data is two-dimensional. The model should learn from this data, how groups are split, and when a new point would come, it should be able to classify it and assign it to the correct group. Even there are very few data points available for the training, the model is still able to learn the correct representation. This is the main point of this example — to keep it simple and reproducible.

The sample application is available on GitHub repo. To run it on your machine, follow these steps:

  1. yarn install
  2. yarn start

The main logic is implemented in src/App.js file. Let’s start from there. In React, you code UI and JS logic in the same JS file, this is convenient.

#machine-learning #javascript #tensorflowjs #react

TensorFlow.js Blueprint App
1.35 GEEK