We recently tested out both Brain.js and Tensorflow.js prototypes for a spam filtration app that used machine learning to automatically find and flag users with the most public comments that the app determined to be spam within a social network.  This was an attempt to maintain user privacy while improving the user experience by automatically flagging users if and when they appeared to be posting a large number of spam comments. For the training model, we used a bunch of common spam comment phrases such as “satisfaction guaranteed”, “act now”, etc in our data.json file saved under the category “spam” and non spam comments saved as “notSpam”.  The neural network architecture that we used to train our model was Long Short Term Memory, which is well suited for classification related machine learning tasks.

    Tensorflow.js provided robust LSTM options for a spam classification focused neural network and many frameworks to enhance and/or simplify the process, but had a moderate learning curve to learn and get working.  Brain.js was relatively easy to set up and use, worked well during our tests, and ultimately became our choice for simple machine learning framework. The only tweak that we needed to make was to lower the number of network iterations through the training data from 2000 to 200 to make the system faster when an interaction with a user required a lower latency response time.  While Brain.js is great for small/medium size applications, Tensorflow is one of the most popular machine learning frameworks and should be considered for larger scale applications.


Additional Reading: