Introduction xix
Part 1 Fundamentals of Machine Learning 1
Chapter 1 Introduction to Machine Learning 3
What is Machine Learning? 4
Tools Commonly Used by Data Scientists 4
Common Terminology 5
Real-World Applications of Machine Learning 7
Types of Machine Learning Systems 8
Supervised Learning 9
Unsupervised Learning 10
Semisupervised Learning 11
Reinforcement Learning 11
Batch Learning 12
Incremental Learning 12
Instance-Based Learning 13
Model-Based Learning 13
Common Machine Learning Algorithms 13
Linear Regression 14
Support Vector Machines 15
Logistic Regression 19
Decision Trees 21
Artificial Neural Networks 23
Sources of Machine Learning Datasets 24
Scikit-learn Datasets 24
AWS Public Datasets 27
Kaggle.com Datasets 27
UCI Machine Learning Repository 27
Summary 28
Chapter 2 The Machine-Learning Approach 29
The Traditional Rule-Based Approach 29
A Machine-Learning System 33
Picking Input Features 34
Preparing the Training and Test Set 39
Picking a Machine-Learning Algorithm 40
Evaluating Model Performance 41
The Machine-Learning Process 44
Data Collection and Preprocessing 44
Preparation of Training, Test, and Validation Datasets 44
Model Building 45
Model Evaluation 45
Model Tuning 45
Model Deployment 46
Summary 46
Chapter 3 Data Exploration and Preprocessing 47
Data Preprocessing Techniques 47
Obtaining an Overview of the Data 47
Handling Missing Values 57
Creating New Features 60
Transforming Numeric Features 62
One-Hot Encoding Categorical Features 64
Selecting Training Features 65
Correlation 65
Principal Component Analysis 68
Recursive Feature Elimination 70
Summary 71
Chapter 4 Implementing Machine Learning on Mobile Apps 73
Device-Based vs Server-Based Approaches 73
Apple’s Machine Learning Frameworks and Tools 75
Task-Level Frameworks 75
Model-Level Frameworks 76
Format Converters 76
Transfer Learning Tools 77
Third-Party Machine-Learning Frameworks and Tools 78
Summary 79
Part 2 Machine Learning with CoreML, CreateML, and TuriCreate 81
Chapter 5 Object Detection Using Pre- trained Models 83
What is Object Detection? 83
A Brief Introduction to Artificial Neural Networks 86
Downloading the ResNet50 Model 92
Creating the iOS Project 92
Creating the User Interface 95
Updating Privacy Settings 100
Using the Resnet50 Model in the iOS Project 100
Summary 109
Chapter 6 Creating an Image Classifier with the Create ML App 111
Introduction to the Create ML App 112
Creating the Image Classification Model with the Create ML App 113
Creating the iOS Project 117
Creating the User Interface 118
Updating Privacy Settings 122
Using the Core ML Model in the iOS Project 123
Summary 132
Chapter 7 Creating a Tabular Classifier with Create ML 135
Preparing the Dataset for the Create ML App 135
Creating the Tabular Classification Model with the Create ML App 143
Creating the iOS Project 147
Creating the User Interface 148
Using the Classification Model in the iOS Project 156
Testing the App 172
Summary 173
Chapter 8 Creating a Decision Tree Classifier r 175
Decision Tree Recap 175
Examining the Dataset 176
Creating Training and Test Datasets 180
Creating the Decision Tree Classification Model with Scikit-learn 181
Using Core ML Tools to Convert the Scikit-learn Model to the Core ML Format 186
Creating the iOS Project 187
Creating the User Interface 188
Using the Scikit-learn Decision Tree Classifier Model in the iOS Project 193
Testing the App 201
Summary 202
Chapter 9 Creating a Logistic Regression Model Using Scikit-learn and Core ML 203
Examining the Dataset 203
Creating a Training and Test Dataset 208
Creating the Logistic Regression Model with Scikit-learn 210
Using Core ML Tools to Convert the Scikit-learn Model to the Core ML Format 216
Creating the iOS Project 218
Creating the User Interface 219
Using the Scikit-learn Model in the iOS Project 225
Testing the App 232
Summary 233
Chapter 10 Building a Deep Convolutional Neural Network with Keras 235
Introduction to the Inception Family of Deep Convolutional Neural Networks 236
GoogLeNet (aka Inception-v1) 236
Inception-v2 and Inception-v3 238
Inception-v4 and Inception-ResNet 239
A Brief Introduction to Keras 244
Implementing Inception-v4 with the Keras Functional API 246
Training the Inception-v4 Model 259
Exporting the Keras Inception-v4 Model to the Core ML Format 269
Creating the iOS Project 270
Creating the User Interface 271
Updating Privacy Settings 276
Using the Inception-v4 Model in the iOS Project 277
Summary 286
Appendix A Anaconda and Jupyter Notebook Setup 287
Installing the Anaconda Distribution 287
Creating a Conda Python Environment 288
Installing Python Packages 291
Installing Jupyter Notebook 293
Summary 296
Appendix B Introduction to NumPy and Pandas 297
NumPy 297
Creating NumPy Arrays 297
Modifying Arrays 301
Indexing and Slicing 304
Pandas 305
Creating Series and Dataframes 305
Getting Dataframe Information 307
Selecting Data 311
Summary 313
Index 315