Read more
by John Paul Mueller and Luca Massaron
at a Glance
Part 1: Introducing How Machines Learn
Getting the Real Story about AI
Learning in the Age of Big Data
Having a Glance at the Future
Part 2: Preparing Your Learning Tools
Installing an R Distribution
Coding in R Using RStudio
Installing a Python Distribution
Coding in Python Using Anaconda
Exploring Other Machine Learning Tools
Part 3: Getting Started with the Math Basics
Demystifying the Math Behind Machine Learning
Descending the Right Curve
Validating Machine Learning
Starting with Simple Learners. 199
Part 4: Learning from Smart and Big Data
Preprocessing Data
Leveraging Similarity
Working with Linear Models the Easy Way
Hitting Complexity with Neural Networks
Going a Step beyond Using Support Vector Machines
Resorting to Ensembles of Learners
Part 5: Applying Learning to Real Problems
Classifying Images
Scoring Opinions and Sentiments
Recommending Products and Movies
Part 6: The Part of Tens
Ten Machine Learning Packages to Master
Ten Ways to Improve Your Machine Learning Models
Book Details
Price

2.50 USD 

Pages
 435 p 
File Size

12,094 KB 
File Type

PDF format 
ISBN ISBN ePDF
 9781119245513 9781119245773 (ebk) 9781119245759 (ebk) 
Copyright
 2016 by John Wiley & Sons, Inc 
The main purpose of Machine Learning For Dummies is to help you understand what
machine learning can and can’t do for you today and what it might do for you in
the future. You don’t have to be a computer scientist to use this book, even though
it does contain many coding examples. In fact, you can come from any discipline
that heavily emphasizes math because that’s how this book focuses on machine
learning. Instead of dealing with abstractions, you see the concrete results of
using specific algorithms to interact with big data in particular ways to obtain a
certain, useful result. The emphasis is on useful because machine learning has the
power to perform a wide array of tasks in a manner never seen before.
Part of the emphasis of this book is on using the right tools. This book uses both
Python and R to perform various tasks. These two languages have special features
that make them particularly useful in a machine learning setting. For example,
Python provides access to a huge array of libraries that let you do just about anything
you can imagine and more than a few you can’t. Likewise, R provides an ease
of use that few languages can match. Machine Learning For Dummies helps you understand
that both languages have their role to play and gives examples of when one
language works a bit better than the other to achieve the goals you have in mind.
You also discover some interesting techniques in this book. The most important is
that you don’t just see the algorithms used to perform tasks; you also get an
explanation of how the algorithms work. Unlike many other books, Machine Learning
For Dummies enables you to fully understand what you’re doing, but without
requiring you to have a PhD in math. After you read this book, you finally have a
basis on which to build your knowledge and go even further in using machine
learning to perform tasks in your specific field.
Of course, you might still be worried about the whole programming environment
issue, and this book doesn’t leave you in the dark there, either. At the beginning,
you find complete installation instructions for both RStudio and Anaconda, which
are the Integrated Development Environments (IDEs) used for this book. In addition,
quick primers (with references) help you understand the basic R and Python
programming that you need to perform. The emphasis is on getting you up and
running as quickly as possible, and to make examples straightforward and simple
so that the code doesn’t become a stumbling block to learning.
To help you absorb the concepts, 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.
»»Words that we want you to type in that are also in italics are used as placeholders,
which means that you need to replace them 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.
»»We also use italics for terms we define. This means that you don’t have to rely
on other sources to provide the definitions you need.
»»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 the live link to visit that website, like this: http://www.dummies.com.
»»When you need to click command sequences, you see them separated by a
special arrow, like this: File ➪ New File, which tells you to click File and then New File.
Introduction
The term machine learning has all sorts of meanings attached to it today,
especially after Hollywood’s (and others’) movie studios have gotten into
the picture. Films such as Ex Machina have tantalized the imaginations of
moviegoers the world over and made machine learning into all sorts of things that
it really isn’t. 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 their makers into believing
they’re human). Machine Learning For Dummies provides you with 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 realize that these mundane tasks have the
power to impact the lives of everyone on the planet in nearly every aspect of their
daily lives. In short, machine learning is an incredible technology — just not in
the way that some people have imagined.
Table of Contents
INTRODUCTION . 1
About This Book. 1
Foolish Assumptions. 2
Icons Used in This Book. 3
Beyond the Book. 4
Where to Go from Here. 5
PART 1: INTRODUCING HOW MACHINES LEARN
CHAPTER 1: Getting the Real Story about AI. 9
Moving beyond the Hype. 10
Dreaming of Electric Sheep. 11
Understanding the history of AI and machine
learning. 12
Exploring what machine learning can do for AI . 13
Considering the goals of machine learning. 13
Defining machine learning limits based on hardware. 14
Overcoming AI Fantasies. 15
Discovering the fad uses of AI and machine learning. 16
Considering the true uses of AI and machine
learning. 16
Being useful; being mundane. 18
Considering the Relationship between AI and Machine Learning. 19
Considering AI and Machine Learning Specifications . 20
Defining the Divide between Art and Engineering. 20
CHAPTER 2: Learning in the Age of Big Data. 23
Defining Big Data. 24
Considering the Sources of Big Data . 25
Building a new data source. 26
Using existing data sources. 27
Locating test data sources. 28
Specifying the Role of Statistics in Machine Learning . 29
Understanding the Role of Algorithms. 30
Defining what algorithms do. 30
Considering the five main techniques. 30
Defining What Training Means . 32
CHAPTER 3: Having a Glance at the Future . 35
Creating Useful Technologies for the Future . 36
Considering the role of machine learning in robots 36
Using machine learning in health care. 37
Creating smart systems for various needs . 37
Using machine learning in industrial settings. 38
Understanding the role of updated processors
and other hardware . 39
Discovering the New Work Opportunities with
Machine Learning. 39
Working for a machine. 40
Working with machines . 41
Repairing machines. 41
Creating new machine learning tasks 42
Devising new machine learning environments. 42
Avoiding the Potential Pitfalls of Future Technologies . 43
PART 2: PREPARING YOUR LEARNING TOOLS
CHAPTER 4: Installing an R Distribution. 47
Choosing an R Distribution with Machine Learning in Mind. 48
Installing R on Windows. 49
Installing R on Linux . 56
Installing R on Mac OS X. 57
Downloading the Datasets and Example Code. 59
Understanding the datasets used in this book. 59
Defining the code repository. 60
CHAPTER 5: Coding in R Using RStudio. 63
Understanding the Basic Data Types. 64
Working with Vectors. 66
Organizing Data Using Lists. 66
Working with Matrices . 67
Creating a basic matrix. 68
Changing the vector arrangement. 69
Accessing individual elements. 69
Naming the rows and columns. 70
Interacting with Multiple Dimensions Using Arrays. 71
Creating a basic array. 71
Naming the rows and columns. 72
Creating a Data Frame. 74
Understanding factors . 74
Creating a basic data frame. 76
Interacting with data frames. 77
Expanding a data frame. 79
Performing Basic Statistical Tasks. 80
Making decisions. 80
Working with loops. 82
Performing looped tasks without loops. 84
Working with functions. 85
Finding mean and median. 85
Charting your data .87
CHAPTER 6: Installing a Python Distribution. 89
Choosing a Python Distribution with Machine Learning in Mind. 90
Getting Continuum Analytics Anaconda . 91
Getting Enthought Canopy Express. 92
Getting pythonxy. 93
Getting WinPython . 93
Installing Python on Linux. 93
Installing Python on Mac OS X. 94
Installing Python on Windows. 96
Downloading the Datasets and Example Code. 99
Using Jupyter Notebook. 100
Defining the code repository. 101
Understanding the datasets used in this book. 106
CHAPTER 7: Coding in Python Using Anaconda. 109
Working with Numbers and Logic. 110
Performing variable assignments. 112
Doing arithmetic . 113
Comparing data using Boolean expressions. 115
Creating and Using Strings. 117
Interacting with Dates. 118
Creating and Using Functions. 119
Creating reusable functions. 119
Calling functions . 121
Working with global and local variables. 123
Using Conditional and Loop Statements. 124
Making decisions using the if statement. 124
Choosing between multiple options using nested decisions. 125
Performing repetitive tasks using for. 126
Using the while statement. 127
Storing Data Using Sets, Lists, and Tuples. 128
Creating sets. 128
Performing operations on sets. 128
Creating lists. 129
Creating and using tuples . 131
Defining Useful Iterators . 132
Indexing Data Using Dictionaries . 134
Storing Code in Modules . 134
CHAPTER 8: Exploring Other Machine Learning Tools . 137
Meeting the Precursors SAS, Stata, and SPSS. 138
Learning in Academia with Weka . 140
Accessing Complex Algorithms Easily Using LIBSVM. 141
Running As Fast As Light with Vowpal Wabbit . 142
Visualizing with Knime and RapidMiner. 143
Dealing with Massive Data by Using Spark. 144
PART 3: GETTING STARTED WITH THE MATH BASICS.
CHAPTER 9: Demystifying the Math Behind
Machine Learning. 147
Working with Data. 148
Creating a matrix. 150
Understanding basic operations. 152
Performing matrix multiplication. 152
Glancing at advanced matrix operations. 155
Using vectorization effectively. 155
Exploring the World of Probabilities. 158
Operating on probabilities. 159
Conditioning chance by Bayes’ theorem. 160
Describing the Use of Statistics. 163
CHAPTER 10: Descending the Right Curve. 167
Interpreting Learning As Optimization. 168
Supervised learning. 168
Unsupervised learning. 169
Reinforcement learning. 169
The learning process. 170
Exploring Cost Functions. 173
Descending the Error Curve. 174
Updating by MiniBatch and Online. 177
CHAPTER 11: Validating Machine Learning. 181
Checking OutofSample Errors. 182
Looking for generalization. 183
Getting to Know the Limits of Bias. 184
Keeping Model Complexity in Mind. 186
Keeping Solutions Balanced .188
Depicting learning curves. 189
Training, Validating, and Testing. 191
Resorting to CrossValidation . 191
Looking for Alternatives in Validation .193
CHAPTER 15: Working with Linear Models the Easy Way. 257
Starting to Combine Variables. 258
Mixing Variables of Different Types. 264
Switching to Probabilities. 267
Specifying a binary response. 267
Handling multiple classes. 270
Guessing the Right Features . 271
Defining the outcome of features that don’t work together. 271
Solving overfitting by using selection. 272
Learning One Example at a Time . 274
Using gradient descent. 275
Understanding how SGD is different. 275
CHAPTER 16: Hitting Complexity with Neural Networks. 279
Learning and Imitating from Nature .280
Going forth with feedforward. 281
Going even deeper down the rabbit hole . 283
Getting Back with Backpropagation. 286
Struggling with Overfitting. 289
Understanding the problem . 289
Opening the black box. 290
Introducing Deep Learning . 293
CHAPTER 17: Going a Step beyond Using Support
Vector Machines. 297
Revisiting the Separation Problem: A New Approach . 298
Explaining the Algorithm . 299
Getting into the math of an SVM. 301
Avoiding the pitfalls of nonseparability. 302
Applying Nonlinearity. 303
Demonstrating the kernel trick by example . 305
Discovering the different kernels. 306
Illustrating HyperParameters. 308
Classifying and Estimating with SVM . 309
CHAPTER 18: Resorting to Ensembles of Learners . 315
Leveraging Decision Trees. 316
Growing a forest of trees. 317
Understanding the importance measures. 321
Working with Almost Random Guesses. 324
Bagging predictors with Adaboost. 324
Boosting Smart Predictors. 327
Meeting again with gradient descent. 328
Averaging Different Predictors . 329
PART 5: APPLYING LEARNING TO REAL PROBLEMS
CHAPTER 19: Classifying Images. 333
Working with a Set of Images . 334
Extracting Visual Features . 338
Recognizing Faces Using Eigenfaces. 340
Classifying Images. 343
CHAPTER 20: Scoring Opinions and Sentiments. 349
Introducing Natural Language Processing. 349
Understanding How Machines Read . 350
Processing and enhancing text. 352
Scraping textual datasets from the web . 357
Handling problems with raw text. 360
Using Scoring and Classification. 362
Performing classification tasks. 362
Analyzing reviews from ecommerce. 365
CHAPTER 21: Recommending Products and Movies. 369
Realizing the Revolution. 370
Downloading Rating Data. 371
Trudging through the MovieLens dataset. 371
Navigating through anonymous web data . 373
Encountering the limits of rating data. 374
Leveraging SVD . 375
Considering the origins of SVD. 376
Understanding the SVD connection. 377
Seeing SVD in action. 378
PART 6: THE PART OF TENS
CHAPTER 22: Ten Machine Learning Packages to Master. 385
Cloudera Oryx. 386
CUDAConvnet. 386
ConvNetJS. 387
e1071. 387
gbm. 388
Gensim . 388
glmnet. 388
randomForest . 389
SciPy . 389
XGBoost . 390
CHAPTER 23: Ten Ways to Improve Your Machine
Learning Models. 391
Studying Learning Curves .392
Using CrossValidation Correctly. 393
Choosing the Right Error or Score Metric . 394
Searching for the Best HyperParameters. 395
Testing Multiple Models. 395
Averaging Models. 396
Stacking Models. 396
Applying Feature Engineering. 397
Selecting Features and Examples. 397
Looking for More Data. 398
INDEX . 399
Beyond the Book
This book isn’t the end of your R, Python, or machine learning experience — it’s
really just the beginning. We provide online content to make this book more flexible
and better able to meet your needs. That way, as we receive email from you,
we can address questions and tell you how updates to R, Python, or their associated
addons affect book content. In fact, you gain access to all these cool
additions:
»»Cheat sheet: You remember using crib notes in school to make a better mark
on a test, don’t you? You do? Well, a cheat sheet is sort of like that. It provides
you with some special notes about tasks that you can do with R, Python,
RStudio, Anaconda, and machine learning that not every other person knows.
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. It
contains really neat information such as finding the algorithms you commonly
need for machine learning.
»»Updates: Sometimes changes happen. For example, we might not have seen
an upcoming change when we looked into our crystal ball during the writing
of this book. In the past, this possibility simply meant that the book became
outdated and less useful, but you can now find updates to the book at
In addition to these updates, check out the blog posts with answers to reader
questions and demonstrations of useful bookrelated techniques at
»»Companion files: Hey! Who really wants to type all the code in the book and
reconstruct all those plots manually? Most readers prefer to spend their time
actually working with R, Python, performing machine learning tasks, and
seeing the interesting things they can do, rather than typing. Fortunately for
you, the examples used in the book are available for download, so all you
need to do is read the book to learn machine learning usage techniques. You
can find these files at http://www.dummies.com/extras/machinelearning.
0