understanding machine learning -...

Download Understanding Machine Learning - Assetsassets.cambridge.org/97811070/57135/frontmatter/9781107057135... · UNDERSTANDING MACHINE LEARNING From Theory to Algorithms Shai Shalev-Shwartz

If you can't read please download the document

Upload: hatram

Post on 06-Feb-2018

232 views

Category:

Documents


2 download

TRANSCRIPT

  • Understanding Machine Learning

    Machine learning is one of the fastest growing areas of computer science,with far-reaching applications. The aim of this textbook is to introducemachine learning, and the algorithmic paradigms it offers, in a princi-pled way. The book provides an extensive theoretical account of thefundamental ideas underlying machine learning and the mathematicalderivations that transform these principles into practical algorithms. Fol-lowing a presentation of the basics of the field, the book covers a widearray of central topics that have not been addressed by previous text-books. These include a discussion of the computational complexity oflearning and the concepts of convexity and stability; important algorith-mic paradigms including stochastic gradient descent, neural networks,and structured output learning; and emerging theoretical concepts such asthe PAC-Bayes approach and compression-based bounds. Designed foran advanced undergraduate or beginning graduate course, the text makesthe fundamentals and algorithms of machine learning accessible to stu-dents and nonexpert readers in statistics, computer science, mathematics,and engineering.

    Shai Shalev-Shwartz is an Associate Professor in the School of ComputerScience and Engineering at The Hebrew University, Israel.

    Shai Ben-David is a Professor in the School of Computer Science at theUniversity of Waterloo, Canada.

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • UNDERSTANDINGMACHINE LEARNING

    From Theory toAlgorithms

    Shai Shalev-ShwartzThe Hebrew University, Jerusalem

    Shai Ben-DavidUniversity of Waterloo, Canada

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • 32 Avenue of the Americas, New York, NY 10013-2473, USA

    Cambridge University Press is part of the University of Cambridge.

    It furthers the Universitys mission by disseminating knowledge in the pursuit ofeducation, learning, and research at the highest international levels of excellence.

    www.cambridge.orgInformation on this title: www.cambridge.org/9781107057135

    c Shai Shalev-Shwartz and Shai Ben-David 2014

    This publication is in copyright. Subject to statutory exceptionand to the provisions of relevant collective licensing agreements,no reproduction of any part may take place without the writtenpermission of Cambridge University Press.

    First published 2014

    Printed in the United States of America

    A catalog record for this publication is available from the British Library.

    Library of Congress Cataloging in Publication dataShalev-Shwartz, Shai.Understanding machine learning : from theory to algorithms /Shai Shalev-Shwartz, The Hebrew University, Jerusalem,Shai Ben-David, University of Waterloo, Canada.

    pages cmIncludes bibliographical references and index.ISBN 978-1-107-05713-5 (hardback)1. Machine learning. 2. Algorithms. I. Ben-David, Shai. II. Title.Q325.5.S475 2014006.31dc23 2014001779

    ISBN 978-1-107-05713-5 Hardback

    Cambridge University Press has no responsibility for the persistence or accuracy ofURLs for external or third-party Internet Web sites referred to in this publicationand does not guarantee that any content on such Web sites is, or will remain,accurate or appropriate.

    Reprinted 2015

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • Triple-S dedicates the book to triple-M

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • Contents

    Preface page xv

    1 Introduction 11.1 What Is Learning? 11.2 When Do We Need Machine Learning? 31.3 Types of Learning 41.4 Relations to Other Fields 61.5 How to Read This Book 71.6 Notation 8

    Part 1 Foundations

    2 A Gentle Start 132.1 A Formal Model The Statistical Learning Framework 132.2 Empirical Risk Minimization 152.3 Empirical Risk Minimization with Inductive Bias 162.4 Exercises 20

    3 A Formal Learning Model 223.1 PAC Learning 223.2 A More General Learning Model 233.3 Summary 283.4 Bibliographic Remarks 283.5 Exercises 28

    4 Learning via Uniform Convergence 314.1 Uniform Convergence Is Sufficient for Learnability 314.2 Finite Classes Are Agnostic PAC Learnable 324.3 Summary 344.4 Bibliographic Remarks 354.5 Exercises 35

    vii

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • viii Contents

    5 The Bias-Complexity Trade-off 365.1 The No-Free-Lunch Theorem 375.2 Error Decomposition 405.3 Summary 415.4 Bibliographic Remarks 415.5 Exercises 41

    6 The VC-Dimension 436.1 Infinite-Size Classes Can Be Learnable 436.2 The VC-Dimension 446.3 Examples 466.4 The Fundamental Theorem of PAC Learning 486.5 Proof of Theorem 6.7 496.6 Summary 536.7 Bibliographic Remarks 536.8 Exercises 54

    7 Nonuniform Learnability 587.1 Nonuniform Learnability 587.2 Structural Risk Minimization 607.3 Minimum Description Length and Occams Razor 637.4 Other Notions of Learnability Consistency 667.5 Discussing the Different Notions of Learnability 677.6 Summary 707.7 Bibliographic Remarks 707.8 Exercises 71

    8 The Runtime of Learning 738.1 Computational Complexity of Learning 748.2 Implementing the ERM Rule 768.3 Efficiently Learnable, but Not by a Proper ERM 808.4 Hardness of Learning* 818.5 Summary 828.6 Bibliographic Remarks 828.7 Exercises 83

    Part 2 From Theory to Algorithms

    9 Linear Predictors 899.1 Halfspaces 909.2 Linear Regression 949.3 Logistic Regression 979.4 Summary 999.5 Bibliographic Remarks 999.6 Exercises 99

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • Contents ix

    10 Boosting 10110.1 Weak Learnability 10210.2 AdaBoost 10510.3 Linear Combinations of Base Hypotheses 10810.4 AdaBoost for Face Recognition 11010.5 Summary 11110.6 Bibliographic Remarks 11110.7 Exercises 112

    11 Model Selection and Validation 11411.1 Model Selection Using SRM 11511.2 Validation 11611.3 What to Do If Learning Fails 12011.4 Summary 12311.5 Exercises 123

    12 Convex Learning Problems 12412.1 Convexity, Lipschitzness, and Smoothness 12412.2 Convex Learning Problems 13012.3 Surrogate Loss Functions 13412.4 Summary 13512.5 Bibliographic Remarks 13612.6 Exercises 136

    13 Regularization and Stability 13713.1 Regularized Loss Minimization 13713.2 Stable Rules Do Not Overfit 13913.3 Tikhonov Regularization as a Stabilizer 14013.4 Controlling the Fitting-Stability Trade-off 14413.5 Summary 14613.6 Bibliographic Remarks 14613.7 Exercises 147

    14 Stochastic Gradient Descent 15014.1 Gradient Descent 15114.2 Subgradients 15414.3 Stochastic Gradient Descent (SGD) 15614.4 Variants 15914.5 Learning with SGD 16214.6 Summary 16514.7 Bibliographic Remarks 16614.8 Exercises 166

    15 Support Vector Machines 16715.1 Margin and Hard-SVM 16715.2 Soft-SVM and Norm Regularization 17115.3 Optimality Conditions and Support Vectors* 175

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • x Contents

    15.4 Duality* 17515.5 Implementing Soft-SVM Using SGD 17615.6 Summary 17715.7 Bibliographic Remarks 17715.8 Exercises 178

    16 Kernel Methods 17916.1 Embeddings into Feature Spaces 17916.2 The Kernel Trick 18116.3 Implementing Soft-SVM with Kernels 18616.4 Summary 18716.5 Bibliographic Remarks 18816.6 Exercises 188

    17 Multiclass, Ranking, and Complex Prediction Problems 19017.1 One-versus-All and All-Pairs 19017.2 Linear Multiclass Predictors 19317.3 Structured Output Prediction 19817.4 Ranking 20117.5 Bipartite Ranking and Multivariate Performance Measures 20617.6 Summary 20917.7 Bibliographic Remarks 21017.8 Exercises 210

    18 Decision Trees 21218.1 Sample Complexity 21318.2 Decision Tree Algorithms 21418.3 Random Forests 21718.4 Summary 21718.5 Bibliographic Remarks 21818.6 Exercises 218

    19 Nearest Neighbor 21919.1 k Nearest Neighbors 21919.2 Analysis 22019.3 Efficient Implementation* 22519.4 Summary 22519.5 Bibliographic Remarks 22519.6 Exercises 225

    20 Neural Networks 22820.1 Feedforward Neural Networks 22920.2 Learning Neural Networks 23020.3 The Expressive Power of Neural Networks 23120.4 The Sample Complexity of Neural Networks 23420.5 The Runtime of Learning Neural Networks 23520.6 SGD and Backpropagation 236

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • Contents xi

    20.7 Summary 24020.8 Bibliographic Remarks 24020.9 Exercises 240

    Part 3 Additional Learning Models21 Online Learning 245

    21.1 Online Classification in the Realizable Case 24621.2 Online Classification in the Unrealizable Case 25121.3 Online Convex Optimization 25721.4 The Online Perceptron Algorithm 25821.5 Summary 26121.6 Bibliographic Remarks 26121.7 Exercises 262

    22 Clustering 26422.1 Linkage-Based Clustering Algorithms 26622.2 k-Means and Other Cost Minimization Clusterings 26822.3 Spectral Clustering 27122.4 Information Bottleneck* 27322.5 A High-Level View of Clustering 27422.6 Summary 27622.7 Bibliographic Remarks 27622.8 Exercises 276

    23 Dimensionality Reduction 27823.1 Principal Component Analysis (PCA) 27923.2 Random Projections 28323.3 Compressed Sensing 28523.4 PCA or Compressed Sensing? 29223.5 Summary 29223.6 Bibliographic Remarks 29223.7 Exercises 293

    24 Generative Models 29524.1 Maximum Likelihood Estimator 29524.2 Naive Bayes 29924.3 Linear Discriminant Analysis 30024.4 Latent Variables and the EM Algorithm 30124.5 Bayesian Reasoning 30524.6 Summary 30724.7 Bibliographic Remarks 30724.8 Exercises 308

    25 Feature Selection and Generation 30925.1 Feature Selection 31025.2 Feature Manipulation and Normalization 31625.3 Feature Learning 319

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • xii Contents

    25.4 Summary 32125.5 Bibliographic Remarks 32125.6 Exercises 322

    Part 4 Advanced Theory26 Rademacher Complexities 325

    26.1 The Rademacher Complexity 32526.2 Rademacher Complexity of Linear Classes 33226.3 Generalization Bounds for SVM 33326.4 Generalization Bounds for Predictors with Low 1 Norm 33526.5 Bibliographic Remarks 336

    27 Covering Numbers 33727.1 Covering 33727.2 From Covering to Rademacher Complexity via Chaining 33827.3 Bibliographic Remarks 340

    28 Proof of the Fundamental Theorem of Learning Theory 34128.1 The Upper Bound for the Agnostic Case 34128.2 The Lower Bound for the Agnostic Case 34228.3 The Upper Bound for the Realizable Case 347

    29 Multiclass Learnability 35129.1 The Natarajan Dimension 35129.2 The Multiclass Fundamental Theorem 35229.3 Calculating the Natarajan Dimension 35329.4 On Good and Bad ERMs 35529.5 Bibliographic Remarks 35729.6 Exercises 357

    30 Compression Bounds 35930.1 Compression Bounds 35930.2 Examples 36130.3 Bibliographic Remarks 363

    31 PAC-Bayes 36431.1 PAC-Bayes Bounds 36431.2 Bibliographic Remarks 36631.3 Exercises 366

    Appendix A Technical Lemmas 369

    Appendix B Measure Concentration 372B.1 Markovs Inequality 372B.2 Chebyshevs Inequality 373B.3 Chernoffs Bounds 373B.4 Hoeffdings Inequality 375

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • Contents xiii

    B.5 Bennets and Bernsteins Inequalities 376B.6 Sluds Inequality 378B.7 Concentration of 2 Variables 378

    Appendix C Linear Algebra 380C.1 Basic Definitions 380C.2 Eigenvalues and Eigenvectors 381C.3 Positive Definite Matrices 381C.4 Singular Value Decomposition (SVD) 381

    References 385Index 395

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • Preface

    The term machine learning refers to the automated detection of meaningful patternsin data. In the past couple of decades it has become a common tool in almost anytask that requires information extraction from large data sets. We are surroundedby a machine learningbased technology: Search engines learn how to bring us thebest results (while placing profitable ads), antispam software learns to filter our e-mail messages, and credit card transactions are secured by a software that learnshow to detect frauds. Digital cameras learn to detect faces and intelligent personalassistance applications on smart-phones learn to recognize voice commands. Carsare equipped with accident-prevention systems that are built using machine learningalgorithms. Machine learning is also widely used in scientific applications such asbioinformatics, medicine, and astronomy.

    One common feature of all of these applications is that, in contrast to more tra-ditional uses of computers, in these cases, due to the complexity of the patterns thatneed to be detected, a human programmer cannot provide an explicit, fine-detailedspecification of how such tasks should be executed. Taking examples from intelli-gent beings, many of our skills are acquired or refined through learning from ourexperience (rather than following explicit instructions given to us). Machine learn-ing tools are concerned with endowing programs with the ability to learn andadapt.

    The first goal of this book is to provide a rigorous, yet easy-to-follow, introductionto the main concepts underlying machine learning: What is learning? How can amachine learn? How do we quantify the resources needed to learn a given concept?Is learning always possible? Can we know whether the learning process succeeded orfailed?

    The second goal of this book is to present several key machine learning algo-rithms. We chose to present algorithms that on one hand are successfully usedin practice and on the other hand give a wide spectrum of different learningtechniques. Additionally, we pay specific attention to algorithms appropriate forlarge-scale learning (a.k.a. Big Data), since in recent years, our world has becomeincreasingly digitized and the amount of data available for learning is dramati-cally increasing. As a result, in many applications data is plentiful and computation

    xv

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

  • xvi Preface

    time is the main bottleneck. We therefore explicitly quantify both the amount ofdata and the amount of computation time needed to learn a given concept.

    The book is divided into four parts. The first part aims at giving an initial rigor-ous answer to the fundamental questions of learning. We describe a generalizationof Valiants Probably Approximately Correct (PAC) learning model, which is a firstsolid answer to the question What is learning? We describe the Empirical RiskMinimization (ERM), Structural Risk Minimization (SRM), and Minimum Descrip-tion Length (MDL) learning rules, which show how a machine can learn. Wequantify the amount of data needed for learning using the ERM, SRM, and MDLrules and show how learning might fail by deriving a no-free-lunch theorem. Wealso discuss how much computation time is required for learning. In the second partof the book we describe various learning algorithms. For some of the algorithms,we first present a more general learning principle and then show how the algorithmfollows the principle. While the first two parts of the book focus on the PAC model,the third part extends the scope by presenting a wider variety of learning models.Finally, the last part of the book is devoted to advanced theory.

    We made an attempt to keep the book as self-contained as possible. However,the reader is assumed to be comfortable with basic notions of probability, linearalgebra, analysis, and algorithms. The first three parts of the book are intendedfor first-year graduate students in computer science, engineering, mathematics, orstatistics. It can also be accessible to undergraduate students with the adequatebackground. The more advanced chapters can be used by researchers intending togather a deeper theoretical understanding.

    ACKNOWLEDGMENTS

    The book is based on Introduction to Machine Learning courses taught by ShaiShalev-Shwartz at Hebrew University and by Shai Ben-David at the University ofWaterloo. The first draft of the book grew out of the lecture notes for the coursethat was taught at Hebrew University by Shai Shalev-Shwartz during 20102013.We greatly appreciate the help of Ohad Shamir, who served as a teaching assistantfor the course in 2010, and of Alon Gonen, who served as TA for the course in20112013. Ohad and Alon prepared a few lecture notes and many of the exercises.Alon, to whom we are indebted for his help throughout the entire making of thebook, has also prepared a solution manual.

    We are deeply grateful for the most valuable work of Dana Rubinstein. Danahas scientifically proofread and edited the manuscript, transforming it from lecture-based chapters into fluent and coherent text.

    Special thanks to Amit Daniely, who helped us with a careful read of theadvanced part of the book and wrote the advanced chapter on multiclass learnabil-ity. We are also grateful for the members of a book reading club in Jerusalem whohave carefully read and constructively criticized every line of the manuscript. Themembers of the reading club are Maya Alroy, Yossi Arjevani, Aharon Birnbaum,Alon Cohen, Alon Gonen, Roi Livni, Ofer Meshi, Dan Rosenbaum, Dana Rubin-stein, Shahar Somin, Alon Vinnikov, and Yoav Wald. We would also like to thankGal Elidan, Amir Globerson, Nika Haghtalab, Shie Mannor, Amnon Shashua, NatiSrebro, and Ruth Urner for helpful discussions.

    www.cambridge.org in this web service Cambridge University Press

    Cambridge University Press978-1-107-05713-5 - Understanding Machine Learning: From Theory to AlgorithmsShai Shalev-Shwartz and Shai Ben-DavidFrontmatterMore information

    http://www.cambridge.org/9781107057135http://www.cambridge.orghttp://www.cambridge.org

    http://www: cambridge: org:

    9781107057135: