O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hands-on Machine Learning with JavaScript

Book Description

A definitive guide to creating an intelligent web application with the best of machine learning and JavaScript

About This Book
  • Solve complex computational problems in browser with JavaScript
  • Teach your browser how to learn from rules using the power of machine learning
  • Understand discoveries on web interface and API in machine learning
Who This Book Is For

This book is for you if you are a JavaScript developer who wants to implement machine learning to make applications smarter, gain insightful information from the data, and enter the field of machine learning without switching to another language. Working knowledge of JavaScript language is expected to get the most out of the book.

What You Will Learn
  • Get an overview of state-of-the-art machine learning
  • Understand the pre-processing of data handling, cleaning, and preparation
  • Learn Mining and Pattern Extraction with JavaScript
  • Build your own model for classification, clustering, and prediction
  • Identify the most appropriate model for each type of problem
  • Apply machine learning techniques to real-world applications
  • Learn how JavaScript can be a powerful language for machine learning
In Detail

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.

Style and approach

This is a practical tutorial that uses hands-on examples to step through some real-world applications of machine learning. Without shying away from the technical details, you will explore machine learning with JavaScript using clear and practical examples.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Machine Learning with JavaScript
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Exploring the Potential of JavaScript
    1. Why JavaScript?
    2. Why machine learning, why now?
    3. Advantages and challenges of JavaScript
    4. The CommonJS initiative
    5. Node.js
    6. TypeScript language
    7. Improvements in ES6
      1. Let and const
      2. Classes
      3. Module imports
      4. Arrow functions
      5. Object literals
      6. The for...of function
      7. Promises
      8. The async/await functions
    8. Preparing the development environment
      1. Installing Node.js
      2. Optionally installing Yarn
      3. Creating and initializing an example project
      4. Creating a Hello World project
    9. Summary
  7. Data Exploration
    1. An overview
    2. Feature identification
      1. The curse of dimensionality
      2. Feature selection and feature extraction
      3. Pearson correlation example
    3. Cleaning and preparing data
      1. Handling missing data
        1. Missing categorical data
        2. Missing numerical data
      2. Handling noise
      3. Handling outliers
      4. Transforming and normalizing data
    4. Summary
  8. Tour of Machine Learning Algorithms
    1. Introduction to machine learning
    2. Types of learning
      1. Unsupervised learning
      2. Supervised learning
        1. Measuring accuracy
        2. Supervised learning algorithms
      3. Reinforcement learning
    3. Categories of algorithms
      1. Clustering
      2. Classification
      3. Regression
      4. Dimensionality reduction
      5. Optimization
      6. Natural language processing
      7. Image processing
    4. Summary
  9. Grouping with Clustering Algorithms
    1. Average and distance
    2. Writing the k-means algorithm
      1. Setting up the environment
      2. Initializing the algorithm
      3. Testing random centroid generation
      4. Assigning points to centroids
      5. Updating centroid locations
      6. The main loop
    3. Example 1 – k-means on simple 2D data
    4. Example 2 – 3D data
    5. k-means where k is unknown
    6. Summary
  10. Classification Algorithms
    1. k-Nearest Neighbor
      1. Building the KNN algorithm
        1. Example 1 – Height, weight, and gender
        2. Example 2 – Decolorizing a photo
    2. Naive Bayes classifier
      1. Tokenization
      2. Building the algorithm
      3. Example 3 – Movie review sentiment
    3. Support Vector Machine
    4. Random forest
    5. Summary
  11. Association Rule Algorithms
    1. The mathematical perspective
    2. The algorithmic perspective
    3. Association rule applications
    4. Example – retail data
    5. Summary
  12. Forecasting with Regression Algorithms
    1. Regression versus classification
    2. Regression basics
    3. Example 1 – linear regression
    4. Example 2 – exponential regression
    5. Example 3 – polynomial regression
    6. Other time-series analysis techniques
      1. Filtering
      2. Seasonality analysis
      3. Fourier analysis
    7. Summary
  13. Artificial Neural Network Algorithms
    1. Conceptual overview of neural networks
    2. Backpropagation training
    3. Example - XOR in TensorFlow.js
    4. Summary
  14. Deep Neural Networks
    1. Convolutional Neural Networks
      1. Convolutions and convolution layers
      2. Example – MNIST handwritten digits
    2. Recurrent neural networks
      1. SimpleRNN
      2. Gated recurrent units
      3. Long Short-Term Memory
    3. Summary
  15. Natural Language Processing in Practice
    1. String distance
    2. Term frequency - inverse document frequency
    3. Tokenizing
    4. Stemming
    5. Phonetics
    6. Part of speech tagging
    7. Word embedding and neural networks
    8. Summary
  16. Using Machine Learning in Real-Time Applications
    1. Serializing models
      1. Training models on the server
      2. Web workers
      3. Continually improving and per-user models
    2. Data pipelines
      1. Data querying
      2. Data joining and aggregation
      3. Transformation and normalization
      4. Storing and delivering data
    3. Summary
  17. Choosing the Best Algorithm for Your Application
    1. Mode of learning
    2. The task at hand
    3. Format, form, input, and output
    4. Available resources
    5. When it goes wrong
    6. Combining models
    7. Summary
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think