ML Map Reduce (Lecture 11) (Máy học với MapReduce)

UN
Uni24h
0 lượt tải
51
0

Nội dung tài liệu

Trang 4

How to MapReduce K-Means? • Given K, assign the first K random points to be the initial cluster centers • Assign subsequent points to the closest cluster using the supplied distance measure • Compute the centroid of each cluster and iterate the previous step until the cluster centers converge within delta • Run a final pass over the points to cluster them for output

Trang 5

K-Means Map/Reduce Design • Driver – Runs multiple iteration jobs using mapper+combiner+reducer – Runs final clustering job using only mapper • Mapper – Configure: Single file containing encoded Clusters – Input: File split containing encoded Vectors – Output: Vectors keyed by nearest cluster • Combiner – Input: Vectors keyed by nearest cluster – Output: Cluster centroid vectors keyed by “cluster” • Reducer (singleton) – Input: Cluster centroid vectors – Output: Single file containing Vectors keyed by cluster

Trang 6

Mapper - mapper has k centers in memory. Input Key-value pair (each input data point x). Find the index of the closest of the k centers (call it iClosest). Emit: (key,value) = (iClosest, x) Reducer(s) – Input (key,value) Key = index of center Value = iterator over input data points closest to ith center At each key value, run through the iterator and average all the Corresponding input data points. Emit: (index of center, new center)

Trang 7

Improved Version: Calculate partial sums in mappers Mapper - mapper has k centers in memory. Running through one input data point at a time (call it x). Find the index of the closest of the k centers (call it iClosest). Accumulate sum of inputs segregated into K groups depending on which center is closest. Emit: ( , partial sum) Or Emit(index, partial sum) Reducer – accumulate partial sums and Emit with index or without

Trang 9

What is MLE? • Given – A sample X={X1, …, Xn} – A vector of parameters θ • We define – Likelihood of the data: P(X | θ) – Log-likelihood of the data: L(θ)=log P(X|θ) • Given X, find  = argmax L() ML 

Trang 10

MLE (cont) • Often we assume that Xis are independently identically distributed (i.i.d.)  = argmax L() ML  = argmax log P(X | )  = argmax log P(X ,..., X | ) 1 n  = argmax log  P(X | ) i  i = argmax logP(X | ) i  i • Depending on the form of p(x|θ), solving optimization problem can be easy or hard.

Trang 11

An easy case • Assuming – A coin has a probability p of being heads, 1-p of being tails. – Observation: We toss a coin N times, and the result is a set of Hs and Ts, and there are m Hs. • What is the value of p based on MLE, given the observation?

Trang 12

An easy case (cont) L() = log P(X |) = log pm (1− p)N−m = mlog p+(N −m)log(1− p) dL() d(mlog p+(N −m)log(1− p)) m N −m = = − = 0 dp dp p 1− p p= m/N

Trang 13

Basic setting in EM • X is a set of data points: observed data • Θ is a parameter vector. • EM is a method to find θML where  = argmax L() ML  = argmax log P(X | )  • Calculating P(X | θ) directly is hard. • Calculating P(X,Y|θ) is much simpler, where Y is “hidden” data (or “missing” data).

Trang 14

The basic EM strategy • Z = (X, Y) – Z: complete data (“augmented data”) – X: observed data (“incomplete” data) – Y: hidden data (“missing” data)

Trang 15

The log-likelihood function • L is a function of θ, while holding X constant: L( | X) = L() = P(X |) l() = log L() = log P(X |) n = log P(x |) i i=1 n = logP(x |) i i=1 n  = log P(x , y |) i i=1 y

Trang 16

The iterative approach for MLE  = argmax L() ML  = argmax l()  n  = argmax log p(x , y |) i  i=1 y In many cases, we cannot find the solution directly. An alternative is to find a sequence: 0 ,1,...,t ,.... s.t. l(0 )  l(1) ...  l(t ) ....

Trang 17

l() −l(t ) = log P(X |) − log P(X |t ) n  n  = log P(x , y |) − log P(x , y |t ) i i i=1 y i=1 y P(x , y |) n i = log y i=1 P(x , y |t ) i y n  P(x , y |) = log  i i=1 y P(x , y'|t ) i y' n  P(x , y |) P(x , y |t ) = log  i  i i=1 y P(x , y'|t ) P(x , y |t ) i i y' n  P(x , y |t ) P(x , y |) = log  i  i i=1 y P(x , y'|t ) P(x , y |t ) i i y' n  P(x , y |) = log P(y | x ,t ) i i P(x , y |t ) i=1 y i n P(x , y |) = log E [ i ] P(y|x ,t ) P(x , y |t ) i i=1 i Jensen’s inequality n P(x , y |)  E [log i ] P(y|x ,t ) P(x , y |t ) i i=1 i

Trang 18

Jensen’s inequality if f is −convex, then E[ f (g(x)]  f (E[g(x]) if f is −concave, then E[ f (g(x)]  f (E[g(x]) log is a concave function E[log( p(x)]  log( E[p(x)])

Trang 19

Maximizing the lower bound n p(x , y |) (t+1) = argmax E [log i ] P(y|x ,t ) p(x , y |t )  i i=1 i n P(x , y |) = argmax P(y | x ,t )log i i P(x , y |t )  i=1 y i n = argmax P(y | x ,t )log P(x , y |) i i  i=1 y n = argmax E [log P(x , y |)] P(y|x ,t ) i  i i=1 The Q function

Trang 20

The Q-function • Define the Q-function (a function of θ): Q(,t ) = E[log P(X,Y |) | X,t ] = E [log P(X,Y |)] P(Y|X ,t )  n = P(Y | X,t )log P(X,Y |) = E [log P(x , y |)] P(y|x ,t ) i i Y i=1 n = P(y | x ,t )log P(x , y |) i i i=1 y – Y is a random vector. – X=(x1, x2, …, xn) is a constant (vector). – Θt is the current parameter estimate and is a constant (vector). – Θ is the normal variable (vector) that we wish to adjust. • The Q-function is the expected value of the complete data log-likelihood P(X,Y|θ) with respect to Y given X and θt.

Hiển thị 20 trang đầu. Tải tài liệu để xem đầy đủ.

Bình luận (0)

Đăng nhập để tham gia bình luận

Chưa có bình luận nào. Hãy là người đầu tiên!