Data mining of massive datasets

Please download to get full document.

View again

of 513
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report
Category:

Data & Analytics

Published:

Views: 35 | Pages: 513

Extension: PDF | Download: 5

Share
Related documents
Description
Data Mining of Massive Datasets Jure Leskovec - Stanford University Anand Rajaraman - Milliway Labs Jeffrey D. Ullman - Stanford University
Transcript
  • 1. Mining of Massive Datasets Jure Leskovec Stanford Univ. Anand Rajaraman Milliway Labs Jeffrey D. Ullman Stanford Univ. Copyright c 2010, 2011, 2012, 2013, 2014 Anand Rajaraman, Jure Leskovec, and Jeffrey D. Ullman
  • 2. ii
  • 3. Preface This book evolved from material developed over several years by Anand Raja- raman and Jeff Ullman for a one-quarter course at Stanford. The course CS345A, titled “Web Mining,” was designed as an advanced graduate course, although it has become accessible and interesting to advanced undergraduates. When Jure Leskovec joined the Stanford faculty, we reorganized the material considerably. He introduced a new course CS224W on network analysis and added material to CS345A, which was renumbered CS246. The three authors also introduced a large-scale data-mining project course, CS341. The book now contains material taught in all three courses. What the Book Is About At the highest level of description, this book is about data mining. However, it focuses on data mining of very large amounts of data, that is, data so large it does not fit in main memory. Because of the emphasis on size, many of our examples are about the Web or data derived from the Web. Further, the book takes an algorithmic point of view: data mining is about applying algorithms to data, rather than using data to “train” a machine-learning engine of some sort. The principal topics covered are: 1. Distributed file systems and map-reduce as a tool for creating parallel algorithms that succeed on very large amounts of data. 2. Similarity search, including the key techniques of minhashing and locality- sensitive hashing. 3. Data-stream processing and specialized algorithms for dealing with data that arrives so fast it must be processed immediately or lost. 4. The technology of search engines, including Google’s PageRank, link-spam detection, and the hubs-and-authorities approach. 5. Frequent-itemset mining, including association rules, market-baskets, the A-Priori Algorithm and its improvements. 6. Algorithms for clustering very large, high-dimensional datasets. iii
  • 4. iv PREFACE 7. Two key problems for Web applications: managing advertising and rec- ommendation systems. 8. Algorithms for analyzing and mining the structure of very large graphs, especially social-network graphs. 9. Techniques for obtaining the important properties of a large dataset by dimensionality reduction, including singular-value decomposition and la- tent semantic indexing. 10. Machine-learning algorithms that can be applied to very large data, such as perceptrons, support-vector machines, and gradient descent. Prerequisites To appreciate fully the material in this book, we recommend the following prerequisites: 1. An introduction to database systems, covering SQL and related program- ming systems. 2. A sophomore-level course in data structures, algorithms, and discrete math. 3. A sophomore-level course in software systems, software engineering, and programming languages. Exercises The book contains extensive exercises, with some for almost every section. We indicate harder exercises or parts of exercises with an exclamation point. The hardest exercises have a double exclamation point. Support on the Web Go to http://www.mmds.org for slides, homework assignments, project require- ments, and exams from courses related to this book. Gradiance Automated Homework There are automated exercises based on this book, using the Gradiance root- question technology, available at www.gradiance.com/services. Students may enter a public class by creating an account at that site and entering the class with code 1EDD8A1D. Instructors may use the site by making an account there
  • 5. PREFACE v and then emailing support at gradiance dot com with their login name, the name of their school, and a request to use the MMDS materials. Acknowledgements Cover art is by Scott Ullman. We would like to thank Foto Afrati, Arun Marathe, and Rok Sosic for critical readings of a draft of this manuscript. Errors were also reported by Rajiv Abraham, Apoorv Agarwal, Aris Anag- nostopoulos, Atilla Soner Balkir, Arnaud Belletoile, Robin Bennett, Susan Bian- cani, Amitabh Chaudhary, Leland Chen, Anastasios Gounaris, Shrey Gupta, Waleed Hameid, Saman Haratizadeh, Rafi Kamal, Lachlan Kang, Ed Knorr, Haewoon Kwak, Ellis Lau, Greg Lee, Ethan Lozano, Yunan Luo, Michael Ma- honey, Justin Meyer, Bryant Moscon, Brad Penoff, Philips Kokoh Prasetyo, Qi Ge, Harizo Rajaona, Rich Seiter, Hitesh Shetty, Angad Singh, Sandeep Sripada, Dennis Sidharta, Krzysztof Stencel, Mark Storus, Roshan Sumbaly, Zack Tay- lor, Tim Triche Jr., Wang Bin, Weng Zhen-Bin, Robert West, Oscar Wu, Xie Ke, Nicolas Zhao, and Zhou Jingbo, The remaining errors are ours, of course. J. L. A. R. J. D. U. Palo Alto, CA March, 2014
  • 6. vi PREFACE
  • 7. Contents 1 Data Mining 1 1.1 What is Data Mining? . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 Statistical Modeling . . . . . . . . . . . . . . . . . . . . . 1 1.1.2 Machine Learning . . . . . . . . . . . . . . . . . . . . . . 2 1.1.3 Computational Approaches to Modeling . . . . . . . . . . 2 1.1.4 Summarization . . . . . . . . . . . . . . . . . . . . . . . . 3 1.1.5 Feature Extraction . . . . . . . . . . . . . . . . . . . . . . 3 1.2 Statistical Limits on Data Mining . . . . . . . . . . . . . . . . . . 4 1.2.1 Total Information Awareness . . . . . . . . . . . . . . . . 5 1.2.2 Bonferroni’s Principle . . . . . . . . . . . . . . . . . . . . 5 1.2.3 An Example of Bonferroni’s Principle . . . . . . . . . . . 6 1.2.4 Exercises for Section 1.2 . . . . . . . . . . . . . . . . . . . 7 1.3 Things Useful to Know . . . . . . . . . . . . . . . . . . . . . . . . 7 1.3.1 Importance of Words in Documents . . . . . . . . . . . . 7 1.3.2 Hash Functions . . . . . . . . . . . . . . . . . . . . . . . . 9 1.3.3 Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1.3.4 Secondary Storage . . . . . . . . . . . . . . . . . . . . . . 11 1.3.5 The Base of Natural Logarithms . . . . . . . . . . . . . . 12 1.3.6 Power Laws . . . . . . . . . . . . . . . . . . . . . . . . . . 13 1.3.7 Exercises for Section 1.3 . . . . . . . . . . . . . . . . . . . 15 1.4 Outline of the Book . . . . . . . . . . . . . . . . . . . . . . . . . 15 1.5 Summary of Chapter 1 . . . . . . . . . . . . . . . . . . . . . . . . 17 1.6 References for Chapter 1 . . . . . . . . . . . . . . . . . . . . . . . 18 2 MapReduce and the New Software Stack 21 2.1 Distributed File Systems . . . . . . . . . . . . . . . . . . . . . . . 22 2.1.1 Physical Organization of Compute Nodes . . . . . . . . . 22 2.1.2 Large-Scale File-System Organization . . . . . . . . . . . 24 2.2 MapReduce . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 2.2.1 The Map Tasks . . . . . . . . . . . . . . . . . . . . . . . . 25 2.2.2 Grouping by Key . . . . . . . . . . . . . . . . . . . . . . . 26 2.2.3 The Reduce Tasks . . . . . . . . . . . . . . . . . . . . . . 27 2.2.4 Combiners . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 vii
  • 8. viii CONTENTS 2.2.5 Details of MapReduce Execution . . . . . . . . . . . . . . 28 2.2.6 Coping With Node Failures . . . . . . . . . . . . . . . . . 30 2.2.7 Exercises for Section 2.2 . . . . . . . . . . . . . . . . . . . 30 2.3 Algorithms Using MapReduce . . . . . . . . . . . . . . . . . . . . 30 2.3.1 Matrix-Vector Multiplication by MapReduce . . . . . . . 31 2.3.2 If the Vector v Cannot Fit in Main Memory . . . . . . . . 32 2.3.3 Relational-Algebra Operations . . . . . . . . . . . . . . . 33 2.3.4 Computing Selections by MapReduce . . . . . . . . . . . 35 2.3.5 Computing Projections by MapReduce . . . . . . . . . . . 36 2.3.6 Union, Intersection, and Difference by MapReduce . . . . 36 2.3.7 Computing Natural Join by MapReduce . . . . . . . . . . 37 2.3.8 Grouping and Aggregation by MapReduce . . . . . . . . . 38 2.3.9 Matrix Multiplication . . . . . . . . . . . . . . . . . . . . 38 2.3.10 Matrix Multiplication with One MapReduce Step . . . . . 39 2.3.11 Exercises for Section 2.3 . . . . . . . . . . . . . . . . . . . 40 2.4 Extensions to MapReduce . . . . . . . . . . . . . . . . . . . . . . 41 2.4.1 Workflow Systems . . . . . . . . . . . . . . . . . . . . . . 41 2.4.2 Recursive Extensions to MapReduce . . . . . . . . . . . . 43 2.4.3 Pregel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 2.4.4 Exercises for Section 2.4 . . . . . . . . . . . . . . . . . . . 46 2.5 The Communication Cost Model . . . . . . . . . . . . . . . . . . 47 2.5.1 Communication-Cost for Task Networks . . . . . . . . . . 47 2.5.2 Wall-Clock Time . . . . . . . . . . . . . . . . . . . . . . . 49 2.5.3 Multiway Joins . . . . . . . . . . . . . . . . . . . . . . . . 49 2.5.4 Exercises for Section 2.5 . . . . . . . . . . . . . . . . . . . 53 2.6 Complexity Theory for MapReduce . . . . . . . . . . . . . . . . . 54 2.6.1 Reducer Size and Replication Rate . . . . . . . . . . . . . 55 2.6.2 An Example: Similarity Joins . . . . . . . . . . . . . . . . 56 2.6.3 A Graph Model for MapReduce Problems . . . . . . . . . 58 2.6.4 Mapping Schemas . . . . . . . . . . . . . . . . . . . . . . 60 2.6.5 When Not All Inputs Are Present . . . . . . . . . . . . . 61 2.6.6 Lower Bounds on Replication Rate . . . . . . . . . . . . . 61 2.6.7 Case Study: Matrix Multiplication . . . . . . . . . . . . . 63 2.6.8 Exercises for Section 2.6 . . . . . . . . . . . . . . . . . . . 67 2.7 Summary of Chapter 2 . . . . . . . . . . . . . . . . . . . . . . . . 68 2.8 References for Chapter 2 . . . . . . . . . . . . . . . . . . . . . . . 70 3 Finding Similar Items 73 3.1 Applications of Near-Neighbor Search . . . . . . . . . . . . . . . 73 3.1.1 Jaccard Similarity of Sets . . . . . . . . . . . . . . . . . . 74 3.1.2 Similarity of Documents . . . . . . . . . . . . . . . . . . . 74 3.1.3 Collaborative Filtering as a Similar-Sets Problem . . . . . 75 3.1.4 Exercises for Section 3.1 . . . . . . . . . . . . . . . . . . . 77 3.2 Shingling of Documents . . . . . . . . . . . . . . . . . . . . . . . 77 3.2.1 k-Shingles . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
  • 9. CONTENTS ix 3.2.2 Choosing the Shingle Size . . . . . . . . . . . . . . . . . . 78 3.2.3 Hashing Shingles . . . . . . . . . . . . . . . . . . . . . . . 79 3.2.4 Shingles Built from Words . . . . . . . . . . . . . . . . . . 79 3.2.5 Exercises for Section 3.2 . . . . . . . . . . . . . . . . . . . 80 3.3 Similarity-Preserving Summaries of Sets . . . . . . . . . . . . . . 80 3.3.1 Matrix Representation of Sets . . . . . . . . . . . . . . . . 81 3.3.2 Minhashing . . . . . . . . . . . . . . . . . . . . . . . . . . 82 3.3.3 Minhashing and Jaccard Similarity . . . . . . . . . . . . . 83 3.3.4 Minhash Signatures . . . . . . . . . . . . . . . . . . . . . 83 3.3.5 Computing Minhash Signatures . . . . . . . . . . . . . . . 84 3.3.6 Exercises for Section 3.3 . . . . . . . . . . . . . . . . . . . 86 3.4 Locality-Sensitive Hashing for Documents . . . . . . . . . . . . . 88 3.4.1 LSH for Minhash Signatures . . . . . . . . . . . . . . . . 88 3.4.2 Analysis of the Banding Technique . . . . . . . . . . . . . 90 3.4.3 Combining the Techniques . . . . . . . . . . . . . . . . . . 91 3.4.4 Exercises for Section 3.4 . . . . . . . . . . . . . . . . . . . 92 3.5 Distance Measures . . . . . . . . . . . . . . . . . . . . . . . . . . 93 3.5.1 Definition of a Distance Measure . . . . . . . . . . . . . . 93 3.5.2 Euclidean Distances . . . . . . . . . . . . . . . . . . . . . 94 3.5.3 Jaccard Distance . . . . . . . . . . . . . . . . . . . . . . . 95 3.5.4 Cosine Distance . . . . . . . . . . . . . . . . . . . . . . . . 95 3.5.5 Edit Distance . . . . . . . . . . . . . . . . . . . . . . . . . 96 3.5.6 Hamming Distance . . . . . . . . . . . . . . . . . . . . . . 97 3.5.7 Exercises for Section 3.5 . . . . . . . . . . . . . . . . . . . 98 3.6 The Theory of Locality-Sensitive Functions . . . . . . . . . . . . 99 3.6.1 Locality-Sensitive Functions . . . . . . . . . . . . . . . . . 100 3.6.2 Locality-Sensitive Families for Jaccard Distance . . . . . . 101 3.6.3 Amplifying a Locality-Sensitive Family . . . . . . . . . . . 102 3.6.4 Exercises for Section 3.6 . . . . . . . . . . . . . . . . . . . 104 3.7 LSH Families for Other Distance Measures . . . . . . . . . . . . . 105 3.7.1 LSH Families for Hamming Distance . . . . . . . . . . . . 105 3.7.2 Random Hyperplanes and the Cosine Distance . . . . . . 106 3.7.3 Sketches . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 3.7.4 LSH Families for Euclidean Distance . . . . . . . . . . . . 108 3.7.5 More LSH Families for Euclidean Spaces . . . . . . . . . . 110 3.7.6 Exercises for Section 3.7 . . . . . . . . . . . . . . . . . . . 110 3.8 Applications of Locality-Sensitive Hashing . . . . . . . . . . . . . 111 3.8.1 Entity Resolution . . . . . . . . . . . . . . . . . . . . . . . 112 3.8.2 An Entity-Resolution Example . . . . . . . . . . . . . . . 112 3.8.3 Validating Record Matches . . . . . . . . . . . . . . . . . 113 3.8.4 Matching Fingerprints . . . . . . . . . . . . . . . . . . . . 114 3.8.5 A LSH Family for Fingerprint Matching . . . . . . . . . . 115 3.8.6 Similar News Articles . . . . . . . . . . . . . . . . . . . . 117 3.8.7 Exercises for Section 3.8 . . . . . . . . . . . . . . . . . . . 118 3.9 Methods for High Degrees of Similarity . . . . . . . . . . . . . . 119
  • 10. x CONTENTS 3.9.1 Finding Identical Items . . . . . . . . . . . . . . . . . . . 119 3.9.2 Representing Sets as Strings . . . . . . . . . . . . . . . . . 120 3.9.3 Length-Based Filtering . . . . . . . . . . . . . . . . . . . . 120 3.9.4 Prefix Indexing . . . . . . . . . . . . . . . . . . . . . . . . 121 3.9.5 Using Position Information . . . . . . . . . . . . . . . . . 123 3.9.6 Using Position and Length in Indexes . . . . . . . . . . . 124 3.9.7 Exercises for Section 3.9 . . . . . . . . . . . . . . . . . . . 127 3.10 Summary of Chapter 3 . . . . . . . . . . . . . . . . . . . . . . . . 127 3.11 References for Chapter 3 . . . . . . . . . . . . . . . . . . . . . . . 130 4 Mining Data Streams 133 4.1 The Stream Data Model . . . . . . . . . . . . . . . . . . . . . . . 133 4.1.1 A Data-Stream-Management System . . . . . . . . . . . . 134 4.1.2 Examples of Stream Sources . . . . . . . . . . . . . . . . . 135 4.1.3 Stream Queries . . . . . . . . . . . . . . . . . . . . . . . . 136 4.1.4 Issues in Stream Processing . . . . . . . . . . . . . . . . . 137 4.2 Sampling Data in a Stream . . . . . . . . . . . . . . . . . . . . . 138 4.2.1 A Motivating Example . . . . . . . . . . . . . . . . . . . . 138 4.2.2 Obtaining a Representative Sample . . . . . . . . . . . . . 139 4.2.3 The General Sampling Problem . . . . . . . . . . . . . . . 139 4.2.4 Varying the Sample Size . . . . . . . . . . . . . . . . . . . 140 4.2.5 Exercises for Section 4.2 . . . . . . . . . . . . . . . . . . . 140 4.3 Filtering Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 4.3.1 A Motivating Example . . . . . . . . . . . . . . . . . . . . 141 4.3.2 The Bloom Filter . . . . . . . . . . . . . . . . . . . . . . . 142 4.3.3 Analysis of Bloom Filtering . . . . . . . . . . . . . . . . . 142 4.3.4 Exercises for Section 4.3 . . . . . . . . . . . . . . . . . . . 143 4.4 Counting Distinct Elements in a Stream . . . . . . . . . . . . . . 144 4.4.1 The Count-Distinct Problem . . . . . . . . . . . . . . . . 144 4.4.2 The Flajolet-Martin Algorithm . . . . . . . . . . . . . . . 145 4.4.3 Combining Estimates . . . . . . . . . . . . . . . . . . . . 146 4.4.4 Space Requirements . . . . . . . . . . . . . . . . . . . . . 146 4.4.5 Exercises for Section 4.4 . . . . . . . . . . . . . . . . . . . 147 4.5 Estimating Moments . . . . . . . . . . . . . . . . . . . . . . . . . 147 4.5.1 Definition of Moments . . . . . . . . . . . . . . . . . . . . 147 4.5.2 The Alon-Matias-Szegedy Algorithm for Second Moments . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 4.5.3 Why the Alon-Matias-Szegedy Algorithm Works . . . . . 149 4.5.4 Higher-Order Moments . . . . . . . . . . . . . . . . . . . 150 4.5.5 Dealing With Infinite Streams . . . . . . . . . . . . . . . . 150 4.5.6 Exercises for Section 4.5 . . . . . . . . . . . . . . . . . . . 152 4.6 Counting Ones in a Window . . . . . . . . . . . . . . . . . . . . . 152 4.6.1 The Cost of Exact Counts . . . . . . . . . . . . . . . . . . 153 4.6.2 The Datar-Gionis-Indyk-Motwani Algorithm . . . . . . . 153 4.6.3 Storage Requirements for the DGIM Algorithm . . . . . . 155
  • 11. CONTENTS xi 4.6.4 Query Answering in the DGIM Algorithm . . . . . . . . . 155 4.6.5 Maintaining the DGIM Conditions . . . . . . . . . . . . . 156 4.6.6 Reducing the Error . . . . . . . . . . . . . . . . . . . . . . 157 4.6.7 Extensions to the Counting of Ones . . . . . . . . . . . . 158 4.6.8 Exercises for Section 4.6 . . . . . . . . . . . . . . . . . . . 159 4.7 Decaying Windows . . . . . . . . . . . . . . . . . . . . . . . . . . 159 4.7.1 The Problem of Most-Common Elements . . . . . . . . . 160 4.7.2 Definition of the Decaying Window . . . . . . . . . . . . . 160 4.7.3 Finding the Most Popular Elements . . . . . . . . . . . . 161 4.8 Summary of Chapter 4 . . . . . . . . . . . . . . . . . . . . . . . . 162 4.9 References for Chapter 4 . . . . . . . . . . . . . . . . . . . . . . . 164 5 Link Analysis 167 5.1 PageRank . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 5.1.1 Early Search Engines and Term Spam . . . . . . . . . . . 168 5.1.2 Definition of PageRank . . . . . . . . . . . . . . . . . . . 169 5.1.3 Structure of the Web . . . . . . . . . . . . . . . . . . . . . 173 5.1.4 Avoiding Dead Ends . . . . . . . . . . . . . . . . . . . . . 174 5.1.5 Spider Traps and Taxation . . . . . . . . . . . . . . . . . 177 5.1.6 Using PageRank in a Search Engine . . . . . . . . . . . . 179 5.1.7 Exercises for Section 5.1 . . . . . . . . . . . . . . . . . . . 180 5.2 Efficient Computation of PageRank . . . . . . . . . . . . . . . . . 182 5.2.1 Representing Transition Matrices . . . . . . . . . . . . . . 182 5.2.2 PageRank Iteration Using MapReduce . . . . . . . . . . . 183 5.2.3 Use of Combiners to Consolidate the Result Vector . . . . 184 5.2.4 Representing Blocks of the Transition Matrix . . . . . . . 185 5.2.5 Other Efficient Approaches to PageRank Iteration . . . . 187 5.2.6 Exercises for Section 5.2 . . . . . . . . . . . . . . . . . . . 187 5.3 Topic-Sensitive PageRank . . . . . . . . . . . . . . . . . . . . . . 188 5.3.1 Motivation for Topic-Sensitive Page Rank . . . . . . . . . 188 5.3.2 Biased Random Walks . . . . . . . . . . . . . . . . . . . . 189 5.3.3 Using Topic-Sensitive PageRank . . . . . . . . . . . . . . 190 5.3.4 Inferring Topics from Words . . . . . . . . . . . . . . . . . 191 5.3.5 Exercises for Section 5.3 . . . . . . . . . . . . . . . . . . . 192 5.4 Link Spam . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 5.4.1 Architecture of a Spam Farm . . . . . . . . . . . . . . . . 192 5.4.2 Analysis of a Spam Farm . . . . . . . . . . . . . . . . . . 194 5.4.3 Combating Link Spam . . . . . . . . . . . . . . . . . . . . 195 5.4.4 TrustRank . . . . . . . . . . . . . . . . . . . . . . . . . . 195 5.4.5 Spam Mass . . . . . . . . . . . . . . . . . . . . . . . . . . 196 5.4.6 Exercises for Section 5.4 . . . . . . . . . . . . . . . . . . . 197 5.5 Hubs and Authorities . . . . . . . . . . . . . . . . . . . . . . . . 197 5.5.1 The Intuition Behind HITS . . . . . . . . . . . . . . . . . 197 5.5.2 Formalizing Hubbiness and Authority . . . . . . . . . . . 198 5.5.3 Exercises for Section 5.5 . . . . . . . . . . . . . . . . . . . 202
  • 12. xii CONTENTS 5.6 Summary of Chapter 5 . . . . . . . . . . . . . . . . . . . . . . . . 202 5.7 References for Chapter 5 . . . . . . . . . . . . . . . . . . . . . . . 205 6 Frequent Itemsets 207 6.1 The Market-Basket Model . . . . . . . . . . . . . . . . . . . . . . 208 6.1.1 De
  • We Need Your Support
    Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

    Thanks to everyone for your continued support.

    No, Thanks