Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

Machine Learning in JavaScript

Most Machine Learning applications uses R or Python.

But these days, several Machine Learning libraries for JavaScript are emerging.

JavaScript libraries make it possible to execute Machine Learning tasks in the browser.

Artificial Intelligence and JavaScript

Machine Learning (ML) has changed the science of Artificial Intelligence (AI), image processing, computer vision, and natural language applications.

Thanks to new libraries, JavaScript developers can now build ML applications without Python or R. This way JavaScript can help developers to bring ML to the browser and to the web.

With ML libraries, JavaScript developers can add Artificial Intelligence to web applications.


Is JavaScript Good for Machine Learning?

Most Machine Learning applications these days use R or Python.

But JavaScript has a great future as an Machine Learning language, and it even has some advantages:

  • JavaScript is better known. All developers can use it.
  • Security is built in. JavaScript cannot access your files.
  • JavaScript is faster than Python.
  • Modern JavaScript compiles into machine code.
  • Modern JavaScript can use hardware acceleration.

WebGL API

WebGL is a JavaScript API for rendering 2d and 3D graphics in any browser.

WebGL can run on both integrated and standalone graphic cards in any PC.

WebGL brings 3D graphics to the web browser. Major browser vendors Apple (Safari), Google (Chrome), Microsoft (Edge), and Mozilla (Firefox) are members of the WebGL Working Group.

WebGL 1.0 was released in March 2011.

WebGL 2.0 was released in January 2017.

JellyFish


Neural Networks with JavaScript

Machine Learning can be math-heavy. The nature of neural networks is highly technical, and the jargon that goes along with it tends to scare people away.

This is where JavaScript can come to help. We need easy to understand software APIs to simplifying the process of creating and training neural networks.


JavaScript Libraries

Brain.js

Brain.js is a JavaScript library that makes it easy to understand Neural Networks because it hides the complexity of the mathematics.

Building a neural network with Brain.js.


Introduction to ml5.js

ml5.js is trying to make machine learning more accessible to a wider audience.

The ml5 team is working to wrap machine learning functionality in friendlier ways.

The example below uses only three lines of code to classify an image:

<img id="image" src="pic1.jpg" width="100%">

<script>
const classifier = ml5.imageClassifier('MobileNet');
classifier.classify(document.getElementById("image"), gotResult);
function gotResult(error, results) { ... }
</script>
Try it Yourself »

Try substitute "pic1.jpg" with "pic2.jpg" and "pic3.jpg".


TensorFlow Playground

TensorFlow Playground is a web application written in d3.js.

With TensorFlow Playground you can learn about Neural Networks (NN) without math.

In your own Web Browser you can create a Neural Network and see the result.

TensorFlow.js was previously called Tf.js and Deeplearn.js.