





































































Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!






































































Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein.
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at [email protected] or (800) 382-3419.
For government sales inquiries, please contact [email protected].
For questions about sales outside the U.S., please contact [email protected].
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2019938761
Copyright © 2020 Pearson Education, Inc.
Cover image: cono0430/Shutterstock
Pages 58, 87: Screenshot of seaborn © 2012–2018 Michael Waskom. Pages 167, 177, 192, 201, 278, 284, 479, 493: Screenshot of seaborn heatmap © 2012–2018 Michael Waskom. Pages 178, 185, 196, 197, 327, 328: Screenshot of seaborn swarmplot © 2012–2018 Michael Waskom. Page 222: Screenshot of seaborn stripplot © 2012–2018 Michael Waskom. Pages 351, 354: Screenshot of seaborn implot © 2012–2018 Michael Waskom. Pages 352, 353, 355: Screenshot of seaborn distplot © 2012–2018 Michael Waskom. Pages 460, 461: Screenshot of Manifold © 2007–2018, scikit-learn developers. Page 480: Screenshot of cluster © 2007–2018, scikit-learn developers. Pages 483, 484, 485: Image of accordion, Vereshchagin Dmitry/Shutterstock. Page 485: Image of fighter jet, 3dgenerator/123RF. Page 525: Screenshot of seaborn jointplot © 2012–2018 Michael Waskom.
All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit www.pearsoned.com/permissions/.
ISBN-13: 978-0-13-484562- ISBN-10: 0-13-484562-
ScoutAutomatedPrintCode
Contents
Foreword xxi
Preface xxiii
About the Author xxvii
1 Let’s Discuss Learning 3 1.1 Welcome 3 1.2 Scope, Terminology, Prediction, and Data 4 1.2.1 Features 5 1.2.2 Target Values and Predictions 6 1.3 Putting the Machine in Machine Learning 7 1.4 Examples of Learning Systems 9 1.4.1 Predicting Categories: Examples of Classifiers 9 1.4.2 Predicting Values: Examples of Regressors 10 1.5 Evaluating Learning Systems 11 1.5.1 Correctness 11 1.5.2 Resource Consumption 12 1.6 A Process for Building Learning Systems 13 1.7 Assumptions and Reality of Learning 15 1.8 End-of-Chapter Material 17 1.8.1 The Road Ahead 17 1.8.2 Notes 17
2 Some Technical Background 19 2.1 About Our Setup 19 2.2 The Need for Mathematical Language 19
3.5 Simple Classifier #1:
x Contents
4.4.5 Application to Linear Regression 101 4.5 Simple Evaluation and Comparison of Regressors 101 4.5.1 Root Mean Squared Error 101 4.5.2 Learning Performance 102 4.5.3 Resource Utilization in Regression 102 4.6 EOC 104 4.6.1 Limitations and Open Issues 104 4.6.2 Summary 105 4.6.3 Notes 105 4.6.4 Exercises 105
5 Evaluating and Comparing Learners 109 5.1 Evaluation and Why Less Is More 109 5.2 Terminology for Learning Phases 110 5.2.1 Back to the Machines 110 5.2.2 More Technically Speaking... 113 5.3 Major Tom, There’s Something Wrong: Overfitting and Underfitting 116 5.3.1 Synthetic Data and Linear Regression 117 5.3.2 Manually Manipulating Model Complexity 118 5.3.3 Goldilocks: Visualizing Overfitting, Underfitting, and “Just Right” 120 5.3.4 Simplicity 124 5.3.5 Take-Home Notes on Overfitting 124 5.4 From Errors to Costs 125 5.4.1 Loss 125 5.4.2 Cost 126
Contents xi
5.4.3 Score 127 5.5 (Re)Sampling: Making More from Less 128 5.5.1 Cross-Validation 128 5.5.2 Stratification 132 5.5.3 Repeated Train-Test Splits 133 5.5.4 A Better Way and Shuffling 137 5.5.5 Leave-One-Out Cross-Validation 140 5.6 Break-It-Down: Deconstructing Error into Bias and Variance 142 5.6.1 Variance of the Data 143 5.6.2 Variance of the Model 144 5.6.3 Bias of the Model 144 5.6.4 All Together Now 145 5.6.5 Examples of Bias-Variance Tradeoffs 145 5.7 Graphical Evaluation and Comparison 149 5.7.1 Learning Curves: How Much Data Do We Need? 150 5.7.2 Complexity Curves 152 5.8 Comparing Learners with Cross-Validation 154 5.9 EOC 155 5.9.1 Summary 155 5.9.2 Notes 155 5.9.3 Exercises 157
6 Evaluating Classifiers 159 6.1 Baseline Classifiers 159 6.2 Beyond Accuracy: Metrics for Classification 161 6.2.1 Eliminating Confusion from the Confusion Matrix 163 6.2.2 Ways of Being Wrong 164 6.2.3 Metrics from the Confusion Matrix 165 6.2.4 Coding the Confusion Matrix 166 6.2.5 Dealing with Multiple Classes: Multiclass Averaging 168
xiv Contents
8.5 Discriminant Analysis 269 8.5.1 Covariance 270 8.5.2 The Methods 282 8.5.3 Performing DA 283 8.6 Assumptions, Biases, and Classifiers 285 8.7 Comparison of Classifiers: Take Three 287 8.7.1 Digits 287 8.8 EOC 290 8.8.1 Summary 290 8.8.2 Notes 290 8.8.3 Exercises 293
9 More Regression Methods 295 9.1 Linear Regression in the Penalty Box: Regularization 295 9.1.1 Performing Regularized Regression 300 9.2 Support Vector Regression 301 9.2.1 Hinge Loss 301 9.2.2 From Linear Regression to Regularized Regression to Support Vector Regression 305 9.2.3 Just Do It—SVR Style 307 9.3 Piecewise Constant Regression 308 9.3.1 Implementing a Piecewise Constant Regressor 310 9.3.2 General Notes on Implementing Models 311 9.4 Regression Trees 313 9.4.1 Performing Regression with Trees 313 9.5 Comparison of Regressors: Take Three 314 9.6 EOC 318 9.6.1 Summary 318 9.6.2 Notes 318 9.6.3 Exercises 319
Contents xvii
13 Models That Engineer Features for Us 409 13.1 Feature Selection 411 13.1.1 Single-Step Filtering with Metric-Based Feature Selection 412 13.1.2 Model-Based Feature Selection 423 13.1.3 Integrating Feature Selection with a Learning Pipeline 426 13.2 Feature Construction with Kernels 428 13.2.1 A Kernel Motivator 428 13.2.2 Manual Kernel Methods 433 13.2.3 Kernel Methods and Kernel Options 438 13.2.4 Kernelized SVCs: SVMs 442 13.2.5 Take-Home Notes on SVM and an Example 443 13.3 Principal Components Analysis: An Unsupervised Technique 445 13.3.1 A Warm Up: Centering 445 13.3.2 Finding a Different Best Line 448 13.3.3 A First PCA 449 13.3.4 Under the Hood of PCA 452 13.3.5 A Finale: Comments on General PCA 457 13.3.6 Kernel PCA and Manifold Methods 458 13.4 EOC 462 13.4.1 Summary 462 13.4.2 Notes 462 13.4.3 Exercises 467
14 Feature Engineering for Domains: Domain-Specific Learning 469 14.1 Working with Text 470 14.1.1 Encoding Text 471 14.1.2 Example of Text Learning 476 14.2 Clustering 479 14.2.1 k -Means Clustering 479