ML5.js: A Friendly Intro to Machine Learning for JS Developers

Machine learning can be two big and scary words to the new Javascript developer, but they don’t have to be! ML5.js makes machine learning fun and accessible to all, and is an easy way to get started exploring the field of artificial intelligence. Today, we’ll take a look at the field of machine learning and how you can get going on your first project that uses AI in the browser.

What is Machine Learning?

Before we dive into getting started with ML5.js, we should have a better understanding of machine learning and how it works. On the surface, Machine Learning is the use of algorithms and statistics to teach computers without being explicitly programmed. However, depending on what you’re looking to achieve, there are many different types of machine learning. The three main types of machine learning we see in the software engineering space are reinforcement learning, supervised learning, and unsupervised learning. Each method teaches the computer using data in a different way:

Reinforcement learning: utilizes a reward system that reinforces positive associations the computer makes with the provided data

Unsupervised learning: is self-guided learning by the computer where it is motivated to find patterns and build a structure in the provided data set n order to find meaning

Supervised learning: feeds the computer a set of labeled data to create a model and ultimately make assumptions/predictions about any new data it’s given

The field of machine learning is vast and has a variety of real-world applications that we encounter every day! Let’s take a look at some examples.

Real-World Applications

Have you noticed that when you’re bored and swiping through Netflix, usually there’s at least one thing that may catch your eye at the top of the page? Or what about when you hit the homepage of Amazon and a book that’s similar to the last book you purchased is sitting in your recommended tab? You can thank machine learning for that!

Services like Netflix and Amazon use machine learning to power their recommendation systems. The more you use their services the more their algorithms learn about you. Each click, purchase, or decision you make on their site is feeding their systems more of your personal data and in turn allowing them to tailor their site to fit your needs.

Entertainment isn’t the only industry where machine learning is prevalent! In healthcare, many machines and systems are designed to catch details that medical professionals may miss and ultimately increase the accuracies of diagnoses.

So how can you harness the power of machine learning? Let’s take a look at ML5.js and how it makes machine learning easy for the modern Javascript engineer…

Using ML5.js

The purpose of ML5.js is to make machine learning easy, approachable, and fun for beginners! There are a number of different applications of machine learning found in the ML5.js library.

One of the most popular features includes image classification. Given an image, ML5.js can spit out a prediction of what object is found in that image along with a confidence rating. You’re also able to use machine learning to classify sound with ML5.js. The sound classification tool allows you to classify audion and detect when certain noises are made. You can also create your own pre-trained speech commands, which opens you up to a wide world of possibilities.

One of the most powerful helpers featured in ML5.js is the feature extractor, which allows you to retrain the models provided by ML5.js for custom tasks.

There are so many powerful tools at your hands using ML5.js, and I’m sure you’re wondering how to get started! Let’s get things going.

Getting Started

The quickest way to get started exploring ML5.js is to paste the following cdn link to the library in your HTML page:

<script src="https://unpkg.com/ml5@latest/dist/ml5.min.js"></script>

Once that’s pasted in you should have access to the latest features available in ML5.js. Feel free to get started right away and don't forget to have fun!

Resources:

https://towardsdatascience.com/introduction-to-ml5-js-3fe51d6a4661