Machine Learning For Dummies - Luca Massaron - E-Book

Machine Learning For Dummies E-Book

Luca Massaron

0,0
22,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

The most human-friendly book on machine learning

Somewhere buried in all the systems that drive artificial intelligence, you'll find machine learning—the process that allows technology to build knowledge based on data and patterns. Machine Learning For Dummies is an excellent starting point for anyone who wants deeper insight into how all this learning actually happens. This book offers an overview of machine learning and its most important practical applications. Then, you'll dive into the tools, code, and math that make machine learning go—and you'll even get step-by-step instructions for testing it out on your own. For an easy-to-follow introduction to building smart algorithms, this Dummies guide is your go-to.

  • Piece together what machine learning is, what it can do, and what it can't do
  • Learn the basics of machine learning code and how it integrates with large datasets
  • Understand the mathematical principles that AI uses to make itself smarter
  • Consider real-world applications of machine learning and write your own algorithms

With clear explanations and hands-on instruction, Machine Learning For Dummies is a great entry-level resource for developers looking to get started with AI and machine learning.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 696

Veröffentlichungsjahr: 2025

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Machine Learning For Dummies®

To view this book's Cheat Sheet, simply go to www.dummies.com and search for “Machine Learning For Dummies Cheat Sheet” in the Search box.

Table of Contents

Cover

Table of Contents

Title Page

Copyright

Introduction

About This Book

Foolish Assumptions

Icons Used in This Book

Beyond the Book

Where to Go from Here

Part 1: Introducing How Machines Learn

Chapter 1: Getting the Real Story About AI

Moving Beyond the Hype

Dreaming of Electric Sheep

Overcoming AI Fantasies

Considering the Relationship Between AI and Machine Learning

Considering AI and Machine Learning Specifications

Defining the Divide Between Art, Science, and Engineering

Predicting the Next AI Winter

Chapter 2: Learning in the Age of Computers

Understanding the Role of Data in Machine Learning

Considering the Sources of Data

Specifying the Role of Statistics in Machine Learning

Understanding the Role of Algorithms

Defining What Training Means

Chapter 3: Having a Glance at the Future

Creating Useful Technologies for the Future

Discovering New Job Opportunities with Machine Learning

Avoiding the Potential Pitfalls of Future Technologies

Part 2: Learning Machine Learning by Coding

Chapter 4: Working with Google Colab

Defining Google Colab

Getting a Google Account

Working with Notebooks

Performing Common Tasks

Using Hardware Acceleration

Viewing Your Notebook

Executing the Code

Sharing Your Notebook

Getting Help

Chapter 5: Understanding the Tools of the Trade

Understanding Hardware Options

Putting Secrets in a Safe Place

Using Magic Functions

Performing Multimedia Integration

Downloading the Datasets and Code

Chapter 6: Getting Beyond Basic Coding in Python

Defining the Basics You Should Know

Storing Data Using Sets, Lists, and Tuples

Indexing Data Using Dictionaries

Understanding the Basics of Classes

Part 3: Building the Foundations

Chapter 7: Demystifying the Math Behind Machine Learning

Working with Data

Exploring the World of Probabilities

Describing the Use of Statistics

Chapter 8: Descending the Gradient

Acknowledging Different Kinds of Learning

The Learning Process

Optimizing with Big Data

Chapter 9: Validating Machine Learning

Considering the Use of Example Data

Checking Out-of-Sample Errors

Training, Validating, and Testing

Optimizing by Cross-Validation

Avoiding Variance of Estimates and Leakage Traps

Part 4: Learning from Smart Algorithms

Chapter 10: Starting with Simple Learners

Discovering the Incredible Perceptron

Growing Greedy Classification Trees

Taking a Probabilistic Turn

Chapter 11: Leveraging Similarity

Measuring Similarity

Using Distances to Locate Clusters

Tuning the K-Means Algorithm

Finding Similarity by K-Nearest Neighbors

Chapter 12: Working with Linear Models the Easy Way

Starting to Combine Features

Mixing Features of Different Types

Switching to Probabilities

Guessing the Right Features

Learning One Example at a Time

Chapter 13: Going Beyond the Basics with Support Vector Machines

Revisiting the Separation Problem

Explaining the Algorithm

Classifying and Estimating with SVM

Chapter 14: Tackling Complexity with Neural Networks

Revising the Perceptron

Understanding Network Learning and Overfitting

Introducing Deep Learning

Chapter 15: Resorting to Ensembles of Learners

Leveraging Decision Trees

Learning from Mistakes and Weak Learners

Boosting via Gradient Descent

Averaging Different Predictors

Part 5: Applying Learning to Real Problems

Chapter 16: Classifying Images

Learning the Magic of Data Augmentation

Revising the State of the Art in Computer Vision

Classifying Images with CNNs

Chapter 17: Scoring Opinions and Sentiments

Introducing Natural Language Processing

Revising the State of the Art in NLP

Understanding How Machines Read

Using Scoring and Classification

Chapter 18: Recommending Products and Movies

Realizing the Revolution of E-Commerce

Downloading Rating Data

Leveraging SVD

Part 6: The Part of Tens

Chapter 19: Ten Ways to Improve Your Machine Learning Models

Studying Learning Curves

Using Cross-Validation Correctly

Choosing the Right Error or Score Metric

Searching for the Best Hyperparameters

Testing Multiple Models

Applying Feature Engineering

Selecting Features

Looking for More Data

Blending Models

Stacking Models

Chapter 20: Ten Guidelines for Ethical Data Usage

Obtaining Permission

Using Sanitization Techniques

Avoiding Inference Pitfalls

Using Generalizations Correctly

Shunning Discriminatory Practices

Detecting Black Swans in Code

Understanding the Process

Considering the Consequences

Balancing Decision-Making

Verifying a Data Source

Index

About the Authors

Connect with Dummies

End User License Agreement

List of Tables

Chapter 1

TABLE 1-1 Comparing Machine Learning to Statistics

Chapter 6

TABLE 6-1 Python Numeric Data Types

TABLE 6-2 Python Binary, Unary, and Bitwise Operators

TABLE 6-3 Python Assignment Operators

TABLE 6-4 Python Relational and Logical Operators

TABLE 6-5 Python Membership and Identity Operators

TABLE 6-6 Python Operator Precedence

List of Illustrations

Chapter 2

FIGURE 2-1: An example of a structured tabular dataset using planetary data.

Chapter 4

FIGURE 4-1: Using Colab commands makes configuring your notebook easy.

FIGURE 4-2: Customize shortcut keys for faster access to commands.

FIGURE 4-3: Colab lets you compare two files to see how they differ.

FIGURE 4-4: Create a new Python 3 notebook.

FIGURE 4-5: Use this dialog box to open existing notebooks.

FIGURE 4-6: When using GitHub, you must provide the URL of the GitHub repositor...

FIGURE 4-7: Your output may differ from the book's output when using Colab.

FIGURE 4-8: Colab maintains a history of the revisions for your project.

FIGURE 4-9: Using GitHub means storing your data in a repository.

FIGURE 4-10: Colab code cells contain a few extras.

FIGURE 4-11: Use Cell panes to keep key cells easily available as needed.

FIGURE 4-12: Colab code cells contain a few extras.

FIGURE 4-13: Use the GUI to make formatting your text easier.

FIGURE 4-14: Hardware acceleration can significantly speed up code execution fo...

FIGURE 4-15: The notebook information includes details like its size on Drive a...

FIGURE 4-16: Colab tracks which code cells you execute and in what order in the...

FIGURE 4-17: Send a message or obtain a link to share your notebook.

Chapter 5

FIGURE 5-1: The secrets section on Google Colab.

FIGURE 5-2: Take your time going through the magic function help; it has a lot ...

FIGURE 5-3: Embedding images can dress up your notebook presentation.

Chapter 8

FIGURE 8-1: Insufficient data makes it hard to map back to the target function.

FIGURE 8-2: Noise can cause mismatches in the data points.

FIGURE 8-3: A plotting of parameter data against the output of the cost functio...

FIGURE 8-4: Visualizing the effect of starting point on outcome.

Chapter 9

FIGURE 9-1: Example of a linear model underfitting a nonlinear relationship in ...

FIGURE 9-2: A K-Nearest Neighbor model appropriately fits the problem on the le...

FIGURE 9-3: Learning curves affected by high bias (left) and high variance (rig...

FIGURE 9-4: A graphical representation of how cross-validation works.

FIGURE 9-5: Comparing grid search to random search.

Chapter 10

FIGURE 10-1: The separating line of a perceptron across two classes.

FIGURE 10-2: A visualization of the decision tree built from the play tennis da...

FIGURE 10-3: A visualization of the pruning alphas and their impurity cost.

FIGURE 10-4: A visualization of the pruned decision tree built from the Titanic...

Chapter 11

FIGURE 11-1: Examples of values plotted as points on a chart.

FIGURE 11-2: Clusters of penguins plotted on a chart based on the first PCA dim...

FIGURE 11-3: Plot of the Calinski and Harabasz score regarding different cluste...

FIGURE 11-4: Penguin species represented by five clusters.

FIGURE 11-5: The bull’s-eye dataset, a nonlinear cloud of points that is diffic...

Chapter 12

FIGURE 12-1: Plotting median house value in California, using latitude and long...

FIGURE 12-2: Adding random features increases in-sample performance but degrade...

FIGURE 12-3: How R

2

varies in training and test sets as iterations increase in ...

Chapter 13

FIGURE 13-1: Comparing different approaches: perceptron, logistic regression, a...

FIGURE 13-2: A case of nonlinearly separable points requiring feature transform...

FIGURE 13-3: An RBF kernel that uses diverse hyperparameters to create unique S...

FIGURE 13-4: A polynomial (left) and an RBF kernel (right) applied to the same ...

Chapter 14

FIGURE 14-1: Learning logical XOR using a single separating line isn’t possible...

FIGURE 14-2: Plots of different activation functions.

FIGURE 14-3: An example of the architecture of a neural network.

FIGURE 14-4: A detail of the feed-forward process in a neural network.

FIGURE 14-5: Overfitting also occurs when too many epochs are performed on the ...

FIGURE 14-6: The bidimensional half-moon problem.

FIGURE 14-7: Dropout temporarily rules out a proportion of the neurons from the...

FIGURE 14-8: Decision boundaries display how a neural network solves the half-m...

FIGURE 14-9: A convolution processes a chunk of an image at a time.

FIGURE 14-10: Some images from the Fashion-MNIST dataset.

FIGURE 14-11: A folded and unfolded RNN cell processing a sequence input.

FIGURE 14-12: The internal structure of an LSTM, with the two memory flows and ...

FIGURE 14-13: The Air Passengers Data.

FIGURE 14-14: Predictions on the last two years of the Air Passengers Data.

Chapter 15

FIGURE 15-1: Comparing a single decision tree output (left) to an ensemble of d...

FIGURE 15-2: Seeing the accuracy of ensembles of different sizes.

FIGURE 15-3: Permutation importance of features computed on the test set.

Chapter 16

FIGURE 16-1: Some common image augmentations.

FIGURE 16-2: Detection, localization, and segmentation example from the Coco da...

FIGURE 16-3: Summary of the neural network we created from scratch.

FIGURE 16-4: The training and validation accuracy plotted across the epochs.

FIGURE 16-5: Summary of the neural network using the pre-trained EfficientNetV2...

Chapter 17

FIGURE 17-1: Summary of the layers and total parameters.

Chapter 18

FIGURE 18-1: The output shows some sample cases and the features from the datas...

FIGURE 18-2: You can obtain a wealth of statistics about the movies.

Guide

Cover

Table of Contents

Title Page

Copyright

Begin Reading

Index

About the Authors

Pages

i

ii

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

Machine Learning For Dummies®, 3rd Edition

Published by: John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030-5774, www.wiley.com

Copyright © 2026 by John Wiley & Sons, Inc. All rights reserved, including rights for text and data mining and training of artificial technologies or similar technologies.

Media and software compilation copyright © 2026 by John Wiley & Sons, Inc. All rights reserved, including rights for text and data mining and training of artificial technologies or similar technologies.

Published simultaneously in Canada

No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without the prior written permission of the Publisher or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 750-4470, or on the web at www.copyright.com. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.

The manufacturer’s authorized representative according to the EU General Product Safety Regulation is Wiley-VCH GmbH, Boschstr. 12, 69469 Weinheim, Germany, e-mail: [email protected].

Trademarks: Wiley, For Dummies, the Dummies Man logo, Dummies.com, Making Everything Easier, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and may not be used without written permission. All other trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or vendor mentioned in this book.

LIMIT OF LIABILITY/DISCLAIMER OF WARRANTY: THE PUBLISHER AND THE AUTHOR MAKE NO REPRESENTATIONS OR WARRANTIES WITH RESPECT TO THE ACCURACY OR COMPLETENESS OF THE CONTENTS OF THIS WORK AND SPECIFICALLY DISCLAIM ALL WARRANTIES, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE. CERTAIN AI SYSTEMS HAVE BEEN USED IN THE CREATION OF THIS WORK. NO WARRANTY MAY BE CREATED OR EXTENDED BY SALES OR PROMOTIONAL MATERIALS. THE ADVICE AND STRATEGIES CONTAINAAED HEREIN MAY NOT BE SUITABLE FOR EVERY SITUATION. THIS WORK IS SOLD WITH THE UNDERSTANDING THAT THE PUBLISHER IS NOT ENGAGED IN RENDERING LEGAL, ACCOUNTING, OR OTHER PROFESSIONAL SERVICES. IF PROFESSIONAL ASSISTANCE IS REQUIRED, THE SERVICES OF A COMPETENT PROFESSIONAL PERSON SHOULD BE SOUGHT. NEITHER THE PUBLISHER NOR THE AUTHOR SHALL BE LIABLE FOR DAMAGES ARISING HEREFROM. THE FACT THAT AN ORGANIZATION OR WEBSITE IS REFERRED TO IN THIS WORK AS A CITATION AND/OR A POTENTIAL SOURCE OF FURTHER INFORMATION DOES NOT MEAN THAT THE AUTHOR OR THE PUBLISHER ENDORSES THE INFORMATION THE ORGANIZATION OR WEBSITE MAY PROVIDE OR RECOMMENDATIONS IT MAY MAKE. FURTHER, READERS SHOULD BE AWARE THAT INTERNET WEBSITES LISTED IN THIS WORK MAY HAVE CHANGED OR DISAPPEARED BETWEEN WHEN THIS WORK WAS WRITTEN AND WHEN IT IS READ.

For general information on our other products and services, please contact our Customer Care Department within the U.S. at 877-762-2974, outside the U.S. at 317-572-3993, or fax 317-572-4002. For technical support, please visit https://hub.wiley.com/community/support/dummies.

Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media that is not included in the version you purchased, you may download this material at http://booksupport.wiley.com. For more information about Wiley products, visit www.wiley.com.

Library of Congress Control Number is available from the publisher.

ISBN 978-1-394-37322-2 (pbk); ISBN 978-1-394-37324-6 (ebk); ISBN 978-1-394-37323-9 (ebk)

Introduction

The term artificial intelligence has all sorts of meanings attached to it today, especially after Hollywood (and other movie studios) have gotten into the picture. Films such as Ex Machina have tantalized the imaginations of moviegoers worldwide, portraying artificial intelligence in ways that misrepresent the technology. As a part of artificial intelligence, machine learning is also widely misunderstood. Of course, most of us have to live in the real world, where machine learning actually does perform an incredible array of tasks that have nothing to do with androids that can pass the Turing Test (fooling a human evaluator into believing they’re human). This book gives you a view of machine learning in the real world and exposes you to the amazing feats you really can perform using this technology.

Even though the tasks that you perform using machine learning may seem a bit mundane when compared to the movie version, by the time you finish this book, you will realize that these mundane tasks have the power to impact nearly every aspect of daily life for people across the planet. In short, machine learning is an incredible technology, just not in the way that some people have imagined.

This third edition of the book features a significant number of changes, not the least of which is the use of Python code to run the examples on Google Colab, as requested by our readers. In addition, the book contains new materials that cover all the progress made since the previous edition.

About This Book

Machines and humans learn in entirely different ways, which is why the first part of this book is essential to your understanding of machine learning. Machines perform routine tasks at incredible speeds, but still require human oversight on many aspects, from how they learn to how they execute their tasks. This book will help you understand how to guide these machines to solve problems that traditionally required human thought.

The second part of this book focuses on utilizing the various Python coding examples on your computer by explaining how to access Google Colab and the example data encountered in the chapters, and using them to learn more from this book.

The third part of the book discusses basic math concepts in relation to machine learning requirements. It prepares you to perform math tasks associated with algorithms used in machine learning to make predictions from your data, such as forecasting a value (regression) or determining a category (classification).

The fourth part of the book helps you discover what to do about data that isn’t quite up to par. This part is also where you start learning about similarity and working with linear models. The most advanced chapter tells you how to work with ensembles of learners to perform tasks that might not otherwise be reasonable to complete.

The fifth part of the book is about the practical application of machine learning techniques. You’ll learn how to perform tasks such as classifying images, analyzing opinions and sentiments, and recommending products and movies, all using machine learning.

The last part of the book contains helpful information to enhance your machine learning experience. This part of the book also includes a chapter specifically focused on ethical data use.

To make absorbing the concepts easy, this book uses the following conventions:

Text that you’re meant to type just as it appears in the book is in

bold

. The exception is when you’re working through a step list: Because each step is bold, the text to type is not bold.

Web addresses and programming code appear in

monofont

. If you're reading a digital version of this book on a device connected to the Internet, you can click or tap the web address to visit that website.

When you need to type command sequences, you see them separated by a special arrow, like this: File ⇒ New File. In this example, you go to the File menu first and then select the New File entry on that menu.

When you see words in

italics

as part of a typing sequence, you need to replace that value with something that works for you. For example, if you see “Type

Your Name

and press Enter,” you need to replace

Your Name

with your actual name.

Foolish Assumptions

This book is designed for novices and professionals alike. You can either read this book from cover to cover or look up topics and treat the book as a reference guide. However, we've made some assumptions about your level of knowledge when we put the book together. You should already be familiar with using your device and working with the operating system that supports it. You also know how to perform tasks like downloading files and installing applications. You can interact with the Internet well enough to locate the resources you need. You know how to work with archives, such as the .zip file format. Finally, a basic knowledge of math is helpful.

Icons Used in This Book

As you read this book, you see icons in the margins that indicate material of interest. This section briefly describes each icon.

The tips in this book are time-saving techniques or pointers to resources that you should try so that you can get the maximum benefit from machine learning.

You should avoid doing anything that’s marked with a Warning icon. Otherwise, you might find that your application fails to work as expected, you get incorrect answers from seemingly bulletproof code, or (in the worst-case scenario) you lose data.

Whenever you see this icon, think advanced tip or technique. Skip these bits of information whenever you like.

This text usually contains an essential process or a bit of information that you must know to perform machine learning tasks successfully.

Beyond the Book

Besides the contents you will find in the book, you can also access other cool materials:

Cheat Sheet:

A cheat sheet provides you with some special notes on things you can do with machine learning that not every other expert knows. You can find the Cheat Sheet for this book at

www.dummies.com

. Type

Machine Learning For Dummies

in the Search box and click the Cheat Sheet option that appears.

Errata:

You can find errata by entering this book’s title in the Search box at

www.dummies.com

, which takes you to this book’s page.

Companion files: The source code is available for download. All the book examples tell you precisely which example project to use. You can find these files on this book’s page at www.dummies.com/go/machinelearningfd3e. Just enter the book title in the Search box, click Books on the page that appears, click the book’s title, and scroll down the page to Downloads.

We’ve also had trouble with the datasets used in the previous edition of this book. Sometimes the datasets change or might become unavailable. Given that you likely don’t want to download a large dataset unless you’re interested in that example, we’ve made the datasets not included by default in a programming package available at https://github.com/lmassaron/ml4dummies_3ed. You don’t actually need to download them, though; the example code will perform that task for you automatically when you run it.

Where to Go from Here

Most people will want to start this book from the beginning, because it contains a good deal of information about how the real-world view of machine learning differs from what movies might tell you. However, if you already have a first grounding in the reality of machine learning, you can always skip to the next part of the book. Chapters 4 and 5 are where you want to go to learn everything you need to run the code using Google Colab. You actually do not need to run the code in the book to learn about machine learning. However, testing some concepts hands-on could prove helpful, and we suggest giving it a try. If you decide to run the examples in the book, consider reviewing Chapter 6, unless you’re already an expert Python coder.

If you’re already an expert with Python and know how machine learning works, you could always skip to Chapter 7. Starting at Chapter 7 will help you get into the examples quickly so that you spend less time on basics and more time with intermediate machine learning tasks. You can always refer to and review the previous materials as needed.

Part 1

Introducing How Machines Learn

IN THIS PART …

Defining what machine learning is and how it relates to AI.

Recognizing the role of data in machine learning.

Understanding the role of statistics in machine learning.

Thinking about where machine learning will take society in the future.

Chapter 1

Getting the Real Story About AI

IN THIS CHAPTER

Getting beyond the hype of artificial intelligence (AI)

Distinguishing AI from machine learning

Understanding the science and engineering in machine learning

Delineating where engineering ends and art begins

Artificial intelligence (AI), the theory and development of computer systems capable of performing tasks that would otherwise require human intelligence, is a vast topic today, and it continues to grow larger all the time, thanks to the constant introduction of new technologies. Despite the complexity of these technologies, most people encounter AI through everyday applications, such as interacting with their digital assistants, receiving shopping recommendations, or creating text, images, and videos to post on social networks using generative AI tools. Talking to your smartphone is both fun and helpful for finding out things like the location of the best sushi restaurant in town or discovering how to get to the concert hall. As you interact with your smartphone, it learns more about the way you talk and makes fewer mistakes in understanding your requests. The capability of your smartphone to comprehend and interpret your unique way of speaking is an example of AI, and it is not the only application available. Part of the technology used to make everything happen is machine learning, which involves the use of various techniques to enable algorithms to make predictions based on historical data records.

You also likely encounter and make use of machine learning and AI all over the place today without really noticing. For example, when smart devices adapt to your preferences over time or when digital assistants improve their understanding of your commands, these are examples of machine learning in action. Likewise, recommender systems, such as those found on Amazon, help you decide what to buy based on criteria like previous purchases or products that complement your current choice. The use of both AI and machine learning is expected to keep increasing over time.

In this chapter, you are introduced to AI and machine learning and discover what it means from several perspectives, including how it affects you as a consumer and as a scientist or engineer. You also find that neither AI nor generative AI equals machine learning, even though the media often confuses all the terms. Machine learning is a crucial component of AI, focusing on predicting outcomes based on available information. Generative AI (genAI), which has recently gained importance in the news and our daily lives, is also part of the broader field of AI, but it serves purposes different from predictive machine learning because it aims to create new content, such as text, images, or videos, based on the instructions you provide.

Moving Beyond the Hype

As any technology becomes bigger, so does the hype, and AI certainly has a lot of hype surrounding it. For one thing, some people have chosen to engage in fear-mongering rather than science by equating AI with killer robots, such as those depicted in the film The Terminator. Actually, your first real experience with a robot is more likely to be in the form of a healthcare assistant or possibly as a coworker. The reality is that you interact with AI and machine learning in far more mundane ways than you might realize.

You may have also heard more about AI than machine learning. AI is currently receiving the lion’s share of attention, but in the form of genAI. As a discipline, AI includes both machine learning and genAI. This chapter helps you understand the relationship between machine learning and AI so that you can better understand how this book enables you to move into a technology that used to appear only within the confines of science fiction novels and films.

Machine learning and AI both have strong engineering components. That is, many aspects of these technologies, particularly the performance and behavior of systems and algorithms, can be measured and optimized through established practices and practical evaluation. In addition, both have strong scientific components, through which researchers test concepts and develop new approaches to simulating or approximating certain aspects of intelligence and decision-making. Finally, machine learning also has an artistic component where intuition, creativity, and experience can play a critical role. This is where a talented practitioner can excel, especially when the results from AI and machine learning may seem counterintuitive, and only the experience and creativity of a skilled practitioner can ensure that models or systems perform as expected.

Dreaming of Electric Sheep

Androids (a specialized kind of robot that looks and acts like a human, such as Data in Star Trek: The Next Generation) and some types of humanoid robots (a kind of robot that has human characteristics but is easily distinguished from a human, such as C-3PO in Star Wars) have become the poster children for AI. They present computers in a form that people can anthropomorphize (give human characteristics to, even though they aren’t human). In fact, it’s entirely possible that one day you won’t be able to distinguish between human and artificial life with ease. Science fiction authors, such as Philip K. Dick, have long predicted such an occurrence, and it seems all too possible today. In his novel “Do Androids Dream of Electric Sheep?” Dick discusses the whole concept of more real than real. The idea appears as part of the plot in the movie Blade Runner. However, some uses of robots today are just plain fun, as seen with robots serving at restaurants. The sections that follow help you understand how close technology currently gets to the ideals presented by science fiction authors and the movies.

For physical androids, the current state of the art is impressive but still not even close to humans. In text-based interactions, some advanced AI can hold remarkable human-like conversations, but don’t be fooled by their linguistic skills, as they lack genuine consciousness or understanding.

Understanding the history of AI and machine learning

There is a reason, other than anthropomorphism, that humans envision the ultimate AI as one that is embodied within some android. Ever since the ancient Greeks, humans have discussed the possibility of placing a mind inside a mechanical body. One such myth is that of a mechanical man called Talos. The fact that the ancient Greeks had complex mechanical devices, of which only one still exists (read about the Antikythera mechanism at www.ancient-wisdom.com/antikythera.htm), suggests that their dreams may have been inspired by more than just fantasy. Throughout the centuries, people have discussed mechanical persons capable of thought (such as Rabbi Judah Loew’s Golem).

AI is built on the hypothesis that mechanizing thought is possible. During the first millennium, Greek, Indian, and Chinese philosophers all explored formal reasoning and logic, which are the building blocks of the idea of mechanizing thought. As early as the 17th century, Gottfried Leibniz, Thomas Hobbes, and René Descartes discussed the potential for rationalizing all thought as simply mathematical symbols. Of course, the complexity of the problem eluded them. The point is that the vision for AI has been around for an incredibly long time, but the implementation of some working AI is relatively new.

The actual birth of AI as we know it today began with Alan Turing’s publication of “Computing Machinery and Intelligence” in 1950 (https://courses.cs.umbc.edu/471/papers/turing.pdf). In this paper, Turing explored the idea of how to determine whether machines can think. Of course, this paper led to the Imitation Game involving three players. Player A is a computer, and Player B is a human. Each must convince Player C (a human who can’t see either Player A or Player B) that they are human. If Player C can’t determine who is human and who isn’t in a consistent way, the computer wins.

A persistent issue with AI is excessive optimism. The problem that scientists are trying to solve with AI is incredibly complex. However, the early optimism of the 1950s and 1960s led scientists to believe that the world would produce intelligent machines in as little as 20 years. After all, machines were doing all sorts of amazing things, such as playing complex games. AI currently has its greatest success in areas such as logistics, data mining, advanced natural language processing (conversational AI), advanced computer vision, medical diagnosis, drug discovery, scientific research (for example, protein folding with models like AlphaFold: https://alphafold.com), software development, and materials science.

Exploring what machine learning can do for AI

Machine learning relies on algorithms to analyze datasets. Currently, machine learning can’t provide the sort of AI that the movies present. Even the best algorithms can’t think, feel, present any form of self-awareness, or exercise free will. Machine learning can identify complex patterns, make predictions, and, with generative models, create new data, performing all these tasks far faster than any human can and at a scale that exceeds human capabilities. As a result, machine learning can help humans work more efficiently. A true AI might eventually emerge when computers can finally excel at the clever learning strategies used by nature:

Evolution of models and architectures (akin to Genetics):

Slow learning over time, from one generation to the next

Supervised Learning (akin to Teaching):

Fast learning from curated sources and explicit guidance

Unsupervised Learning (akin to Exploration):

Discovering hidden patterns or intrinsic structures in data

Reinforcement Learning (akin to Trial-and-Error):

Learning how to choose the best actions through interaction with an environment and receiving rewards or penalties

The current state of AI, then, is one of performing analysis and suggesting or automating actions, but humans must still consider the implications of that analysis and make the necessary moral and ethical decisions. This is because, as AI systems become more integrated into society and their impact and autonomy increase, it becomes crucial to consider how to use AI responsibly and in a manner that is fair, transparent, accountable, secure, and respectful of human rights. Key considerations include mitigating any bias derived from data or algorithms, ensuring data privacy, enabling human control and oversight, and assessing the societal impacts of any AI system used for automation and decision-making.

The main point of confusion between learning and intelligence is that people assume that simply because a machine gets better at its job (learning), it’s also aware (intelligence). Nothing supports this view of machine learning. The same phenomenon occurs when people assume that a computer is purposely causing problems for them. The computer can’t assign emotions and therefore acts only upon the input provided and the instructions contained within an application to process that input.

Considering the goals of machine learning

Currently, AI is based on machine learning, which in turn builds on statistics. Yes, machine learning has a statistical basis, but it makes some different assumptions than statistics do because the goals and approaches are different. Table 1-1 lists some features to consider when comparing machine learning to statistics.

Defining machine learning limits based on hardware

Huge datasets require large amounts of memory. Unfortunately, the requirements don’t end there. When you have vast amounts of data and memory, you must also have processors with multiple cores and high speeds. Modern hardware, such as powerful multi-core CPUs or specialized hardware like NVIDIA graphics processing units (GPUs) or Google’s tensor processing units (TPUs), enables the massive computational demands of machine learning, especially of deep learning models. Such hardware has architectures that allow parallel computing (performing many calculations simultaneously), which is necessary for handling matrix operations in neural networks. Companies that develop specialized hardware have become central to the AI revolution, such as NVIDIA with its GPUs (including the A100 and H100 series) and software platforms (like CUDA). Other specialized hardware, such as Google’s TPUs, which are power-efficient, custom-built chips optimized for speed in running machine learning models, as well as other AI accelerators (AMD, Intel Gaudi, Apple's M-series chips with Neural Engines, and many others), also play a significant role. Without such hardware advancements, the recent breakthroughs in large language models and generative AI would not have been feasible.

TABLE 1-1 Comparing Machine Learning to Statistics

Feature

Machine Learning

Statistics

Data handling

Works with large amounts of structured and unstructured data, aiming at achieving predictive accuracy on unseen data. Consequently, it is crucial to split data into training and test sets.

Methods are focused on hypothesis testing, inference from sample to population, and interpretability.

Data input

The data is sampled, randomized, and transformed to maximize accuracy scoring in the prediction of out-of-sample (or completely new) examples.

Aims to estimate parameters of a population based on an input sample and to quantify the uncertainty of these estimates.

Result

Outputs often include probabilities, scores, or direct predictions, which are used to make informed guesses or decisions.

The output typically includes estimates of parameters, along with measures of uncertainty such as confidence intervals and p-values.

Assumptions

The scientist learns from the patterns in data (data-driven model discovery).

The scientist often starts with a model based on some domain theory.

Distribution

Fewer assumptions are made about the data distribution, or it's learned directly from data.

The scientist tends to assume a well-defined distribution.

Fitting

The scientist creates a best fit, but generalizable, model, having prediction in mind.

The model is fit to the entire sample data to make inferences about the population or to explain relationships within the data.

You will hear more and more often about AI ASICs (Application-Specific Integrated Circuits for Artificial Intelligence). These are specially designed microchips with the type of operations in mind that you need when developing AI technologies, such as matrix multiplications and neural network computations. This specialized design allows them to execute these tasks with maximum efficiency, speed, and lower power consumption. Contrary to CPUs and even GPUs (which can be used for a range of activities), these microchips are not reprogrammable after manufacturing, but they outpace any other solution in the tasks they are designed for.

Apart from the necessary hardware, this book considers some of the following issues as part of making your machine learning experience better:

Obtaining a useful result:

As you work through the book, you discover that you need to obtain a valid result first, before you can refine it. In addition, sometimes tuning an algorithm goes too far, and the result becomes quite fragile (and possibly useless outside a specific dataset).

Asking the right question:

Many people get frustrated when trying to obtain an answer from machine learning because they keep tuning their algorithm without asking a different question. To use hardware efficiently, sometimes you must step back and review the question you’re asking. The question might be wrong, which means that even the best hardware will never find the answer.

Relying on intuition too heavily:

All machine learning questions begin as a hypothesis. A scientist uses intuition to create a starting point for discovering the answer to a question. Failure is more common than success when working through a machine learning experience. Your intuition adds the art to the machine learning experience, but sometimes, intuition is wrong, and you have to revisit your assumptions.

Overcoming AI Fantasies

As with many other technologies, AI and machine learning have both their practical and fantasy or fad uses. Of course, the problems with such uses are many. Even if image creation by generative AI has reached an extreme accuracy in generated details and scenery, for one thing, most people wouldn’t really want a Picasso or another piece of art created in this manner, except as a fad item (because no one had done it before, or it is trendy to have one for a short time). The point of art isn’t in creating an interesting interpretation of a particular real-world representation, but rather in seeing how the artist interpreted it. It was previously believed that computers could only replicate existing artistic styles. However, modern generative AI is increasingly capable of blending styles and producing outputs that can be perceived as novel, though the debate about the true artistic originality of such outputs remains. The following sections discuss AI and machine learning fantasies of various sorts.

Discovering the fad uses of AI and machine learning

AI is entering an era of innovation that you once only read about in science fiction. Given the hype surrounding the idea and possible applications of AI, it can be hard to determine whether a particular AI use is real or simply the dream child of a scientist. The fact is that AI and machine learning will both present potential opportunities to create something amazing, and that we’re already at the stage of creating some of those technologies, but you still need to take what you hear with a huge grain of salt.

To make the future uses of AI and machine learning match the concepts that science fiction has presented over the years, real-world programmers, data scientists, and other stakeholders need to create tools. Nothing happens by magic, even though it may look like magic when you don’t know what’s happening behind the scenes. In order for the fad uses for AI and machine learning to become real-world uses, developers, data scientists, and others need to continue building real-world tools that may be hard to imagine at this point.

Considering the true uses of AI and machine learning

You find AI and machine learning used in a great many applications today. The only problem is that the technology works so well that you don’t know that it even exists. In fact, you might be surprised to find that many devices in your home already make use of both technologies. Both technologies definitely appear in your car, and most especially in the workplace. In fact, the uses for both AI and machine learning number in the millions, all safely out of sight, even when they’re pretty dramatic in nature. Here are just a few of the ways in which you might see AI used:

Fraud detection:

You get a call from your credit card company asking whether you made a particular purchase. The credit card company isn’t being nosy; it’s simply alerting you to the fact that someone else could be making a purchase using your card. The AI embedded within the credit card company’s code detected an unfamiliar spending pattern and alerted someone to it.

Resource scheduling:

Many organizations need to schedule the use of resources efficiently. For example, a hospital may need to determine where to place a patient based on the patient’s needs, availability of skilled experts, and the amount of time the doctor expects the patient to be in the hospital.

Complex analysis:

Humans often need help with complex analysis because there are literally too many factors to consider. For example, the same set of symptoms could indicate more than one problem. A doctor or other expert might need help making a diagnosis in a timely manner to save a patient’s life.

Automation:

Any form of automation can benefit from the addition of AI to handle unexpected changes or events. A problem with some types of automation today is that an unforeseen event, such as an object in the wrong place, can actually cause the automation to stop. Adding AI to the automation can enable it to handle unexpected events and continue as if nothing had happened.

Customer service:

The customer service line you call today may not even have a human behind it. The automation is good enough to follow scripts and use various resources to handle the vast majority of your questions. With good voice inflection (provided by AI as well), you may not even be able to tell that you’re talking with a computer.

Safety systems:

Many of the safety systems found in machines of various sorts today rely on AI to take over the vehicle in a time of crisis. For example, many automatic braking systems rely on AI to stop the car based on all the inputs that a vehicle can provide, such as the direction of a skid.

Machine efficiency:

AI can help control a machine in such a manner as to obtain maximum efficiency. The AI controls the use of resources so that the system doesn’t overshoot speed or other goals. Every ounce of power is used precisely as needed to provide the desired services.

This list doesn’t even begin to scratch the surface. You can find AI used in many other ways. However, beyond the widely publicized AI applications, machine learning powers many specific, often less visible, solutions that might not always be immediately associated with the usual concept of AI in popular discourse. Here are a few uses for machine learning that you might not commonly associate with an AI:

Access control:

In many cases, access control is a yes or no proposition. An employee smartcard grants access to a resource in much the same way that people have used keys for centuries. Some locks do offer the capability to set times and dates when access is allowed, but the coarse-grained control doesn’t really answer every need. By using machine learning, you can determine whether an employee should gain access to a resource based on role and need. For example, an employee can gain access to a training room when the training reflects an employee’s role.

Animal protection:

The ocean might seem large enough to allow animals and ships to coexist without problem. Unfortunately, many animals get hit by boats each year. A machine learning algorithm could allow ships to avoid animals by learning the sounds and characteristics of both the animal and the ship.

Predicting wait times:

Most people don’t like waiting when they have no idea of how long the wait will be. Machine learning allows an application to determine waiting times based on staffing levels, staffing load, complexity of the problems the staff is trying to solve, availability of resources, and so on.

Being useful and being mundane

Even though the movies make it sound like AI is going to make a huge splash, and you do sometimes see some incredible uses for AI in real life, the fact of the matter is that most uses for AI are mundane, even boring. The act of performing this analysis using AI is dull when compared to other sorts of AI activities, but the benefits, such as cost savings and improved results from AI-driven analysis, are substantial.

First, Python developers (see Chapter 6 for an overview of the Python language) have developed a vast array of libraries available to make machine learning easy and effective. The Python open-source community is particularly active in creating libraries that make the development of complex machine learning applications accessible to everyone, as seen with the machine learning library Scikit-learn (https://scikit-learn.org/stable). In addition, numerous resources are available, such as Kaggle (www.kaggle.com), which offers competitions that enable machine learning developers and practitioners to refine their machine learning skills in creating practical applications. The results of these competitions often appear later as part of products that people actually use.

Considering the Relationship Between AI and Machine Learning

Machine learning is only part of what a system requires to become an AI. The machine learning portion of the picture enables an AI to perform these tasks:

Adapt to new circumstances that the original developer didn’t envision

Detect patterns in all sorts of data sources

Create new behaviors based on the recognized patterns

Make decisions based on the success or failure of these behaviors

The use of algorithms to manipulate data is the centerpiece of machine learning. To be successful, a machine learning application must use an appropriate algorithm to achieve a desired result. In addition, the data must lend itself to analysis using the desired algorithm, or it requires careful preparation by scientists.

AI encompasses many other disciplines to simulate the thought process successfully. In addition to machine learning, AI usually includes

Natural language processing:

The act of allowing language input and putting it into a form that a computer can use.

Natural language understanding:

The act of deciphering the language in order to act upon the meaning it provides.

Natural language generation:

The act of creating meaningful language outputs to communicate with humans.

Knowledge representation:

The ability to store information in a form that makes fast access possible.

Planning (in the form of goal seeking):

The ability to use stored information to draw conclusions in

near real time

(almost at the moment it happens, but with a slight delay, sometimes so short that a human won’t notice, but the computer can).

Perception and action (often employed in Robotics):

The ability to perceive the environment and act upon it, sometimes in a physical form.

In fact, you might be surprised to find that the number of disciplines required to create an AI is huge. Consequently, this book exposes you to only a portion of what an AI contains. However, even the machine learning portion of the picture can become complex because understanding the world through the data inputs that a computer receives is a complex task. Just think about all the decisions that you constantly make without thinking about them. For example, just the concept of seeing something and knowing whether you can interact successfully with it can become a complex task.

Considering AI and Machine Learning Specifications

As scientists continue to work with technology and turn hypotheses into theories, the technology becomes more related to engineering (where theories are implemented) than science (where theories are created). As the rules governing a technology become clearer, groups of experts work together to define these rules in written form. The result is a set of specifications (a group of rules that everyone agrees upon).

Eventually, implementations of the specifications become standards that a governing body, such as the IEEE (Institute of Electrical and Electronics Engineers) or a combination of the ISO/IEC (International Organization for Standardization/International Electrotechnical Commission), manages. Although the field is still rapidly developing, AI and machine learning have both been around long enough to have established standards, such as methodologies, benchmarks, and frameworks, for development and risk management. Numerous domain-specific standards and influential frameworks have emerged, such as those from organizations like the National Institute of Standards and Technology (NIST) with its AI risk framework (www.nist.gov/itl/ai-risk-management-framework).

The basis for machine learning is math. Algorithms determine how to interpret data in specific ways. The mathematical basics for machine learning are presented in Part 3 of this book. You discover that algorithms process input data in specific ways and create outputs by learning from data patterns, which are then used to make predictions or generate new content. What isn’t predictable is the data itself. The reason you need AI and machine learning is to decipher the data in a way that allows you to identify patterns and make sense of them.

You can see the details of various algorithms in Part 4, which outlines the algorithms used to perform specific tasks. When you get to Part 5, you begin to see the best practices, common approaches, and established methods when using algorithms to perform tasks. The point is to use an algorithm that will best suit the data you have at hand to achieve the specific goals you’ve created. Professionals implement algorithms using programming languages that are best suited for the task. Machine learning relies on Python and R, as well as, to some extent, MATLAB, Java, Julia, and C++.

Defining the Divide Between Art, Science, and Engineering

AI and machine learning are considered to be, at the same time, scientific disciplines, engineering fields, and even art forms for good reasons. First, there are the scientific aspects that guide the research focused on machine learning. The scientific elements of AI involve hypothesis testing, experimentation, and the discovery of knowledge to be applied in solving practical problems. This brings us to the engineering aspect, as building machine learning systems that work effectively and solve problems requires software engineering, system design, and optimization of these systems.

The artistic element of machine learning, instead, takes many forms. Choosing the proper data, features, models, and hyperparameters often requires intuition and experience. There are no specific step-by-step instructions, like cooking recipes, to follow to obtain your result. Every problem presents different challenges and multiple acceptable solutions. You can only experiment creatively and iterate numerous times, looking for your way to solve the problem using machine learning algorithms, guided by intuition and sometimes ingenuity.

Even trivial activities related to machine learning, such as data cleaning, can involve an element of judgment and experience that influences the outcome. How a scientist prepares the data for use is the key. Some tasks, such as removing duplicate records, occur regularly. However, a scientist may also choose to filter the data in some ways or look at only a subset of the data. As a result, the cleaned dataset used by one scientist for machine learning tasks may not precisely match the cleaned dataset used by another.

As a practitioner, you can also tune the algorithms in specific ways or, in this case, more as a researcher, refine how the algorithm works. Again, the goal is to generate output that reveals the desired patterns, allowing you to make sense of the data. For example, when analyzing a picture, a machine learning algorithm must determine which elements of the image reveal its contents and which elements are irrelevant. The answer to that question is crucial if the algorithm is to correctly classify the elements in the image and achieve specific goals.

When working in a machine learning environment, you also have the problem of input data to consider. For example, the microphone found in one smartphone won’t produce precisely the same input data that a microphone in another smartphone will. The characteristics of the microphones differ, yet the result of interpreting the vocal commands provided by the user must remain the same. Likewise, environmental noise changes the input quality of the vocal command, and the smartphone can experience certain forms of electromagnetic interference. Clearly, the variables that a designer faces when creating a machine learning environment are both large and complex.

The art behind the engineering is an essential part of machine learning. The experience that a scientist gains in working through data problems is essential because it provides the means for the scientist to make informed choices that make the algorithm work better. A finely tuned algorithm can make the difference between a robot successfully threading a path through obstacles and hitting every one of them.

Predicting the Next AI Winter

The development of machine learning and AI has become increasingly relentless and unstoppable for several reasons, including the availability of more powerful hardware and vast amounts of data (much of it generated by the Internet) to feed algorithms. Businesses, however, don’t care about the progress alone; they are looking for new ways to generate cash quickly based on these technologies. Obviously, that’s not easy because new technologies like AI do not fit neatly into the existing framework since they are disruptive and so new that you lack guidance and experience on how to gain profit from them. Developer-entrepreneurs exacerbate the problem by overselling technologies. They suggest that the state of the art is more advanced than it actually is, often to secure funding, increase their influence, or advance their careers. In the past, because of the difference between timing and expectations, machine learning and AI have both experienced AI winters, a period of time when businesses show little to no interest in developing new processes, technologies, or strategies. At this very moment, the winds are in favor of AI development, as investments and resources are being poured in, and there is considerable excitement in every industry about the potential returns this technology promises. However, a sudden cool-off may always be around the corner, possibly caused by some unmet expectation that could throw investors into disillusionment. Other slowdowns may also contribute, driven by external factors such as climate change, economic downturns, or geopolitical risks.