Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Hands-on Machine Learning with JavaScript

You're reading from   Hands-on Machine Learning with JavaScript Solve complex computational web problems using machine learning

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788998246
Length 356 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Burak Kanber Burak Kanber
Author Profile Icon Burak Kanber
Burak Kanber
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Exploring the Potential of JavaScript FREE CHAPTER 2. Data Exploration 3. Tour of Machine Learning Algorithms 4. Grouping with Clustering Algorithms 5. Classification Algorithms 6. Association Rule Algorithms 7. Forecasting with Regression Algorithms 8. Artificial Neural Network Algorithms 9. Deep Neural Networks 10. Natural Language Processing in Practice 11. Using Machine Learning in Real-Time Applications 12. Choosing the Best Algorithm for Your Application 13. Other Books You May Enjoy

Example 2 – 3D data

Because we've written the k-means algorithm to handle any arbitrary number of dimensions, we can also test it with 3D data (or 10D, or 100D or any number of dimensions that you require). While this algorithm will work for more than three dimensions, we have no way of visually plotting the higher dimensions and therefore can't visually check the results—so we'll test with 3D data and move on.

Open up data.js and add the following to the middle of the file—anywhere preceding the export default line is OK:

const example_3d3k = [
[1, 1, 1],
[1, 2, 1],
[2, 1, 2],
[2, 2, 3],
[2, 4, 3],
[5, 4, 5],
[5, 3, 4],
[6, 2, 6],
[5, 3, 6],
[6, 4, 7],
[9, 1, 4],
[10, 2, 5],
[9, 2, 5],
[9, 2, 4],
[10, 3, 3]
];

And then modify the export line to look like this (add the example_3d3k variable to the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime