MapReduce for Bayesian Network Parameter Learning using the EM Algorithm

Transcription

1 apreduce for Bayesian Network Parameter Learning using the E Algorithm Aniruddha Basak Carnegie ellon University Silicon Valley Campus NASA Research Park, offett Field, CA Irina Brinster Carnegie ellon University Silicon Valley Campus NASA Research Park, offett Field, CA Ole J. engshoel Carnegie ellon University Silicon Valley Campus NASA Research Park, offett Field, CA Abstract This work applies the distributed computing framework apreduce to Bayesian network parameter learning from incomplete data. We formulate the classical Expectation aximization (E) algorithm within the apreduce framework. Analytically and experimentally we analyze the speed-up that can be obtained by means of apreduce. We present details of the apreduce formulation of E, report speed-ups versus the sequential case, and carefully compare various Hadoop cluster configurations in experiments with Bayesian networks of different sizes and structures. 1 Introduction Parameter learning is one of the key issues in Bayesian networks (BNs), which are widely used in artificial intelligence, machine learning, statistics, and bioinformatics [11]. Expectation aximization (E) is an iterative algorithm for learning statistical models, including BNs from data with missing values or latent variables [3]. E, which we here use for parameter estimation in BNs, is a powerful technique as it guarantees convergence to a local maximum of the log-likelihood function [8]. Due to its numerical stability and ease of implementation, E has become the algorithm of choice in many areas. E has been succesfully applied to Bayesian clustering [7] in machine learning and computer vision. Other applications span gene clustering, motif finding, and protein identification in computational biology as well as medical imaging and word alignment in machine translation [4]. One of the ways to speed-up parameter estimation in graphical models, including Bayesian networks, focuses on parallelizing the inference step, which introduces the main computational bottleneck in many machine learning algorithms. Theoretical analysis of the parallel implementation of belief propagation has been developed [5]. Near linear parallel scaling has been demonstrated by parallelization of the junction tree (JT) inference using OpenP and PI [10]. A Belief propagation algorithm has been accelerated on GPU [14] and on a CPU-GPGPU heterogenous system [6]. Though E has been implemented on apreduce for a variety of tasks, other than our work [1], we are not aware of any formulation of apreduce algorithm for learning from incomplete data in BNs. apreduce is a programming framework and associated implementation for distributed computing on large data sets [2]. apreduce requires decomposition of a program into map and reduce steps, so that multiple mappers and reducers perform in parallel. However, the reducers start only after all mappers have finished. Hadoop apreduce provides a framework for distributing the data and user-specified map-reduce jobs across a large number of cluster nodes or machines. It is based on the master/slave architecture. 1 In the following, a Hadoop node might denote a tasktracker or 1 1

2 jobtracker machine. A map task describes the work executed by a mapper on one input split and generates intermediate key-value pairs. A reduce task is the task of processing records with the same intermediate key. In this work, Hadoop is run on the Amazon Elastic Compute Cloud (EC2) - a web service that provides reconfigurable compute resources. This work applies apreduce to Bayesian parameter learning from incomplete data [1]. In our apreduce E (RE) formulation, the inference step is performed independently for each data record. By running inference in parallel, we accelerate each iteration of E, speeding up the computation as the data set size increases. We present an analytical framework for understanding the scalability and achievable speed-up of RE versus the sequential E algorithm, and test the performance of RE on a variety of BNs for a wide range of data sizes. We find, somewhat surprisingly, that for networks with large junction trees RE outperforms sequential E from data sets containing as few as 20 records (samples). 2 apreduce E Algorithm (RE) In our apreduce E algorithm (RE), we decompose the basic E algorithm for parameter learning from incomplete data. Since all records in the input data are independent of each other, calculation of the expected sufficient statistics can proceed in parallel. The input records can be split between multiple mappers, each running the E-step. In the maximization step (-step), the pseudocounts are used to produce a new estimate of the BN parameters. The -step is performed on the reducers. E-Step: Each mapper takes as input BN structure β, current estimate of parameters θ t, a junction tree (JT) decomposition of the BN structure T, and incomplete data D [9]. It runs the E-step on its input records and accumulates pseudo-counts [x i, π xi ] for all child-parents combinations in a hash map. Once the mapper processes all records assigned to it, it emits an intermediate key-value pair for each hash map entry. The emitted key contains state assignments to parents of the node X i π xi, whereas the value represents the child variable assignment x i appended with the soft counts [x i, π xi ] for this entry. This intermediate key makes sure that all variables with the same parents are grouped and processed in the same reduce task. -Step: Each reduce method performs the -step for families with the same parent assignment: it iterates through all the values with the same key, parses the value, and fills a hash map, in which keys correspond to child-parent combinations and their states, and values correspond to the soft counts. Values are summed up to obtain the parent count. Finally, each reduce function emits an output key-value pair for each hash map entry. The output key is of the form x i, π xi ; the output value represents a newly estimated parameter θ t+1 x i π xi, i.e. θ t+1 x i π xi = [x i, π xi ]/ [π xi ]. The pseudo code and description of our implementation are presented in [1]. 3 Analysis of Execution Time We derive analytical expressions for runtime of one iteration of a sequential E (SE) and RE. In SE, the E-step consists of two steps: computing marginals using belief propagation and calculating pseudocounts for all input data records. If the time taken by these steps for each data record are t bp and t pc respectively, the total time to complete this phase for n input records is T Es = [t bp + t pc ]n. In the -step all parameters in the CPT are recalculated and this requires calculation of parent counts. As the total time required for this phase is directly proportional to the number of parameters ( θ ) of the Bayesian network, we get T s = t c1 θ. Since implementation is sequential, the total time (T seq ) taken by one E iteration is, T seq = [t bp + t pc ]n + t c1 θ. (1) In RE, the E-step and -step are done by mappers and R reducers present in the compute cluster. Unlike the sequential E, at the end of each RE iteration the newly computed BN parameters need to be updated in the HDFS so that every mapper gets these values before the beginning of the E step in the next iteration. Thus, along with E and steps there is an Update BN step. After some derivations (shown in the Appendix), we get the time for one RE iteration as T mr (t bp + t pc ) + t c2 θ, (2) 2

3 where t c2 is a constant for a compute-cluster, aggregating the effect of the last three terms in (7). From (1) and (8) we compute the speed-up (Ψ) for the RE algorithm compared to SE, Ψ = T seq T mr (t bp + t pc )n + t c1 θ (t bp + t pc ) n + tc2 θ = an + b cn + d. (3) As n increases in (3), the numerator (T seq ) increases at a higher rate compared to the denominator (T mr ). At some point T seq exceeds T mr, making Ψ > 1; we call Ψ = 1 a speed-up cross-over point. The cross-over point is interesting because it tells us the data set size for which we benefit from using Hadoop. For sufficiently large values of n (depends on network parameters) we get (t bp + t pc ) n tc2 θ. In this situation, RE algorithm reaches its peak performance with speed-up Ψ max =. However, for very small values of n (n ) and t c1 < t c2, RE can be slower than SE. 4 Experiments on Hadoop 4.1 Experimental Set Up We experiment with three types of EC2 compute nodes: small, medium, and large instances. 2 We test the SE and RE implementations on a number of complex BNs 3 with varying size and structure (see Table 1) that originate from different problem domains. The BNs include several variants of ADAPT BNs representating electrical power systems, based on the ADAPT testbed provided by NASA for benchmarking of system health management applications [13, 12]. 4 All algorithms are implemented in Java. In the RE analysis, we calculate speed-ups based on per-iteration execution time which is measured as the average of the runtime across 10 iterations of the E algorithm Speed-up for varying BNs and Data Sets From equations (1) and (8), the runtimes of both sequential and RE increase linearly with increasing number of data records but at different rates. In this section, we compare sequential E and RE for input records varying from 1 to 100K. Both are executed on small Amazon EC2 instances and 4 mapper nodes have been used for RE, thus = 4. Figure 1 shows the plots of achieved speed-ups of RE relative to the sequential version in semilogarithmic scale. arkers denote the experimental data, while continuous lines represent the rational function (an + b)/(cn + d) fit to the data. The best fit is achieved for small ADAPT BNs that also get up to 4x speed-ups (linear with the number of compute nodes). This behavior is consistent with our mathematical analysis of Ψ, and confirms that the input data-size required to gain close to optimal performance improvement (Ψ Ψ max ) depends on the BN to a great extent. The cross-over point for which the sequential runtime exceeds the runtime on Hadoop also depends on the type and size of network. The cross-over points for different BNs networks run on the Amazon EC2 small instance with four mapper nodes are shown in Table 1. For networks with large JTs (unin2, unin3, or Water), running Hadoop starts giving a meaningful speedup for data sets with 200 records or less (see Table 1 and Figure 1).This result is expected since for complex networks, the cluster start-up overhead quickly becomes negligible compared to the runtime of inference. In this case, distributing workload across multiple nodes pays off even for small training sets. Yet, for ADAPT T1 the cross-over point is shifted to 2.8K data records - a point at which inference runtime in sequential code becomes comparable to the cluster set-up time. Figure 1 also shows that for unin2 having the largest total JT size, Ψ never reaches Ψ max = 4. This reminds us of the limitations of the distributed computing instance we are using. For a big JT, the heap memory allocated to the Java Virtual achines is almost exhausted which requires garbage collection to process more records. Consequently, much longer time is required to complete iterations of RE for very large networks with sufficiently high data sizes. Using edium or Large instances would help to counteract this effect as they have more memory available to be allocated as heap space Other than ADAPT: networks.html 4 ADAPT: mengshoel/29/ 3

4 Table 1: Summary of BNs used in experiments Bayesian Nodes N Edges E Number Junction Cross-over points Network (BN) of parameters θ Tree (JT) Size (Ψ = 1) ADAPT T ,504 1,690 2,800 ADAPT P ,913 32, ADAPT T ,281 36, Water ,484 3,465, unin3 1,044 1,315 85,855 3,113, unin2 1,003 1,244 83,920 4,861,824 5 Speed Up ADAPT_T1 ADAPT_P2 ADAPT_T2 unin3 Water unin Data Set Size in Thousands of Records Time (sec) (1) T1, 10K records T1, 100K records T2, 10K records P2, 10K records 1.36 (4) 2.38 (7) 3.4 (10) 4.42 (13) Cost in $/hr (Hadoop nodes) Figure 1: Speed-up of RE relative to sequential E for data set sizes ranging from 1 to 100K records. Figure 2: Performance of RE on different networks for varying cost Trade-off Between Cost and Performance It is important to find the Hadoop configuration that gives a good trade-off between cost and performance. In this section we consider five Hadoop configurations, with uniformly increasing cost associated from one to thirteen nodes. We experiment with four different BNs and data set sizes. Figure 2 shows the results from these experiments. As cost increases, the execution time generally decreases, as expected. However, the performance after seven Hadoop nodes is marginal, while the total cost increases at a linear rate. Hence, we can conclude that for our implementation, the edium instance with seven Hadoop nodes (which is a knee point) provides a reasonable trade-off between cost and performance. 5 Conclusion We have applied the apreduce framework to Bayesian network parameter learning from incomplete data. We found that the benefit of using apreduce depends strongly not only on the size of the input data set (as is well known) but also on the size and structure of the BN. We have shown that for BNs with large JTs, apreduce E can give speed-up compared to sequential E for just a handful of input records. ore generally, this work improves the understanding of how to optimize the use of apreduce and Hadoop when applied to the important task of BN parameter learning. 6 Acknowledgements This material is based, in part, upon work supported by NSF awards CCF and ECCS

6 Appendix Let the tuple β = (X, W, P) be a BN, where (X,W) is a directed acyclic graph, with n = X nodes, m = W edges, and associated set of conditional probability distributions P = {Pr(X 1 Π X1 ),, Pr(X n Π Xn )}. Here, P r(x i Π Xi ) is the conditional probability distribution for X i X also called conditional probability table (CPT). If X i is a root node, we define Π Xi = {} and thus P contains the probabilities of the root nodes. We use π xi for the parent assignments of node X i, [xi, π xi ] for counts of all the child-parents combinations, and c i for pseudo counts. Using these notoations, we will calculate the runtime of each iteration of RE algorithm. ap phase: In RE, each mapper processes at most records from the input file. As mappers execute concurrently, the time required to complete the E-step in RE is T Emr = (t bp + t pc ) + t trns θ, (4) where t trns reflects the time to transmitt each key-vlaue pair over the network. We considered this time to be a part of E-step. This time is proportional to the size of transmitted data θ for each mapper. Reduce phase: The mappers emit key-value pairs where keys are parent assignments π xi. Let us define a set Ξ to represent all possible parent assignments for the network β, i.e. Ξ = {π xi π xi V al(π Xi ) X i X}. We will denote the members of the set Ξ as ξ j and its cardinality as Ξ. Hence each mapper can emit at most Ξ intermediate keys. All values associated with every intermediate key ξ j for j [1, Ξ ] will generate one reduce task which results in Ξ reduce tasks. So each of the R Reducers in the apreduce framework will be assigned at most Ξ R reduce tasks (assuming no task failed). Each reduce task obtains the parent counts and re-estimate the parameters θ xi π xi as mentioned in Section 3.4. Among all key-value pairs emitted by each mapper, those pairs will have the same key ξ j which correspond to node assignments associated with same parent assignment i.e {(x i, [x i, π xi ]) π xi = ξ j }. We will denote this set as ν ξj and note that, ν ξ1 + ν ξ2 + ν ξ ν ξ Ξ = θ. (5) As all the intermediate key-value pairs emitted by all mappers are accumulated by apreduce, the maximum possible values with key ξ j is ν ξj. Hence a reducer with r (r Ξ R ) reduce tasks will take maximum time to finish if ( ν ξ1 + ν ξ ν ξr ) is maximum for it. Thus the time taken by the -step in RE is, r T mr = ( ν ξk t h + ν ξk t div ), r Ξ R k=1 = (t h + t div ) r ν ξk (6) k=1 Update phase: At the end of each iteration the file in HDFS containing the CPT is updated with the recently calculated values. If writing one entry to the file takes t write (say) time, total time required to update the entire CPT is T Umr = t write θ. Hence, the total time taken by one iteration of RE is, T mr = T Emr + T mr + T Umr (7) r = (t bp + t pc ) + t prop θ + (t h + t div ) ν ξk + t write θ. As equation (5) implies r k=1 ν ξ k θ, we can approximate T mr as follows, T mr (t bp + t pc ) + t c2 θ, (8) k=1 6

Chapter 7 Using Hadoop Cluster and MapReduce Modeling and Prototyping of RMS for QoS Oriented Grid Page 152 7. Using Hadoop Cluster and MapReduce for Big Data Problems The size of the databases used in

MapReduce and Implementation Hadoop Parallel Data Processing Kai Shen A programming interface (two stage Map and Reduce) and system support such that: the interface is easy to program, and suitable for

Evaluating HDFS I/O Performance on Virtualized Systems Xin Tang xtang@cs.wisc.edu University of Wisconsin-Madison Department of Computer Sciences Abstract Hadoop as a Service (HaaS) has received increasing

What is Analytic Infrastructure and Why Should You Care? Robert L Grossman University of Illinois at Chicago and Open Data Group grossman@uic.edu ABSTRACT We define analytic infrastructure to be the services,

- Chung-Cheng Li and Kuochen Wang Department of Computer Science National Chiao Tung University Hsinchu, Taiwan 300 shinji10343@hotmail.com, kwang@cs.nctu.edu.tw Abstract One of the most important issues

A Scalable Network Monitoring and Bandwidth Throttling System for Cloud Computing N.F. Huysamen and A.E. Krzesinski Department of Mathematical Sciences University of Stellenbosch 7600 Stellenbosch, South

Introduction to Hadoop Miles Osborne School of Informatics University of Edinburgh miles@inf.ed.ac.uk October 28, 2010 Miles Osborne Introduction to Hadoop 1 Background Hadoop Programming Model Examples

Finding the M Most Probable Configurations Using Loopy Belief Propagation Chen Yanover and Yair Weiss School of Computer Science and Engineering The Hebrew University of Jerusalem 91904 Jerusalem, Israel

MapReduce Tushar B. Kute, http://tusharkute.com What is MapReduce? MapReduce is a framework using which we can write applications to process huge amounts of data, in parallel, on large clusters of commodity

RESEARCH ISSUES IN DATAA MINING Sanjeev Kumar I.A.S.R.I., Library Avenue, Pusa, New Delhi-110012 sanjeevk@iasri.res.in 1. Introduction The field of data mining and knowledgee discovery is emerging as a