Book Image

Hands-on Machine Learning with JavaScript

Book Image

Hands-on Machine Learning with JavaScript

Overview of this book

In over 20 years of existence, JavaScript has been pushing beyond the boundaries of web evolution with proven existence on servers, embedded devices, Smart TVs, IoT, Smart Cars, and more. Today, with the added advantage of machine learning research and support for JS libraries, JavaScript makes your browsers smarter than ever with the ability to learn patterns and reproduce them to become a part of innovative products and applications. Hands-on Machine Learning with JavaScript presents various avenues of machine learning in a practical and objective way, and helps implement them using the JavaScript language. Predicting behaviors, analyzing feelings, grouping data, and building neural models are some of the skills you will build from this book. You will learn how to train your machine learning models and work with different kinds of data. During this journey, you will come across use cases such as face detection, spam filtering, recommendation systems, character recognition, and more. Moreover, you will learn how to work with deep neural networks and guide your applications to gain insights from data. By the end of this book, you'll have gained hands-on knowledge on evaluating and implementing the right model, along with choosing from different JS libraries, such as NaturalNode, brain, harthur, classifier, and many more to design smarter applications.
Table of Contents (14 chapters)

Preface

I started my first deep dive into machine learning (ML) back in 2008 when I was developing algorithms for adaptive traction control systems for electric cars. Shortly thereafter, I moved out of the mechanical engineering field and co-founded a marketing technology startup. Within a few weeks, I realized how important ML was going to be for me and my company, and I decided to read every book and paper on ML that I could find.

I spent the next couple of years with my nose to the grindstone, reading dozens of textbooks and hundreds of academic papers, writing every algorithm I could find from scratch, and slowly developing an intuition and philosophy around ML.

During that period, I discovered a few things about the ML ecosystem that I wasn't too happy with. There was a strong culture of gatekeeping at the time. The idea of writing ML in a language other than Python was considered absurd. There was a sentiment that only people who had gone to school to study ML could possibly be successful in the field. Much of the publicly available reading material, such as blog articles and tutorials online, was written in a distinctly mathematical tone, thereby alienating readers who were unfamiliar with linear algebra and vector calculus.

At the same time, I was teaching a JavaScript (JS) programming bootcamp and many of my students—self-taught web developers—expressed an interest in ML. It was difficult for me to point them in the right direction; their only option at the time was to move to Python.

This was frustrating to me because I knew that my students were smart enough to grasp ML, and I also knew that ML didn't need to be confined to Python. I also got the sense that many of the developers using the popular Python libraries didn't actually understand the mechanism of the algorithms and would run into problems when trying to implement them. The gatekeeping had backfired and only served to reduce this powerful family of algorithms into black boxes that were applied carelessly by developers that were discouraged from digging deeper and learning more.

I wanted to prove to the world that ML could be taught to anyone and written in any language, so I started writing a series of articles called Machine Learning in JavaScript. The articles taught ML algorithms from first principles, free of jargon and with a focus on implementation rather than mathematical description.

I chose JS for a few reasons. First, the lack of ML libraries in JS would force my readers to write their own implementations and discover for themselves that ML isn't magic, just code. Second, JS hadn't truly come into its own yet (Node.js didn't exist at the time) and was generally considered a poor choice of programming language for serious problems, but I wanted to prove that ML could be written in any language. Finally, I wanted to use a language that most web developers, particularly self-taught developers, would be comfortable with. Choosing a backend language such as PHP or Java would mean excluding a large portion of developers, so I chose the language that every web developer knows: JS.

The series, though dated now, was a hit. Over a million people have read my articles, and I have heard from many readers that my articles inspired them to start on a new path; I consider this among my greatest professional successes.

This book is a humble and modern update to my Machine Learning in JavaScript series. Much has changed since 2008. JS is now the most popular programming language, and ML is being rapidly democratized. Developers can use AWS or Google Cloud to summon immense computational resources with a single API call, and the smartphones of today rival the processing power of desktop computers from a decade ago.

Similarly to my old article series, this book will teach you ML algorithms from first principles. We'll focus on developing the concepts and implementations of ML without straying too far into the mathematical description. Unlike the old series, however, the JS landscape of today actually has ML libraries and implementations available. At times, therefore, we will write our own algorithms and at other times we will rely on existing libraries.

The goal of this book is not to teach you every ML algorithm that exists, nor to make you an expert in any one algorithm. Instead, my goal is to teach you, an experienced web developer, what you need to know to get started and get comfortable with ML so that you can begin your own educational journey with confidence.