


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



We continue to assume a \market-basket" mo del for data, and we visualize the data as a b o olean matrix, where rows = baskets and columns = items. Key assumptions:
While marketing applications generally care only ab out high supp ort (it do esn't pay to try to market things that nob o dy buys anyway), there are several applications that meet the mo del ab ove, esp ecially the p oint ab out pairs of columns/items with low supp ort but high correlation b eing interesting:
Think of a column as the set of rows in which the column has a 1. Then the similarity of two columns C 1 and C 2 is S im(C 1 ; C 2 ) = jC 1 \ C 2 j=jC 1 [ C 2 j.
Example 3.1 :
0 1 1 0 1 1 = 2/5 = 40% similar 0 0 1 1 0 1
2
Key idea: map (\hash") each column C to a small amount of data [the signature, S ig (C )] such that:
An idea that do esn't work: Pick 100 rows at random, and make that string of 100 bits b e the signature for each column. The reason is that the matrix is assumed sparse, so many columns will have an all-0 signature even if they are quite dissimilar. Useful convention: given two columns C 1 and C 2 , we'll refer to rows as b eing of four typ es | a; b; c; d | dep ending on their bits in these columns, as follows:
Typ e C 1 C 2 a 1 1 b 1 0 c 0 1 d 0 0
We'll also use a as \the numb er of rows of typ e a," and so on.
Note, S im(C 1 ; C 2 ) = a=(a + b + c).
But since most rows are of typ e d, a selection of, say, 100 random rows will b e all of typ e d, so the similarity of the columns in these 100 rows is not even de ned.
Imagine the rows p ermuted randomly in order. \Hash" each column C to h(C ), the numb er of the rst row in which column C has a 1.
The probability that h(C 1 ) = h(C 2 ) is a=(a + b + c), since the hash values agree if the rst row with a 1 in either column is of typ e a, and they disagree if the rst such row is of typ e b or c. Note this probability is the same as S im(C 1 ; C 2 ).
If we rep eat the exp eriment, with a new p ermutation of rows a large numb er of times, say 100, we get a signature consisting of 100 row numb ers for each column. The \similarity" of these lists (fraction of p ositions in which they agree) will b e very close to the similarity of the columns.
Imp ortant trick: we don't actually p ermute the rows, which would take many passes over the entire data. Rather, we read the rows in whatever order, and hash each row using (say) 100 di erent hash functions. For each column we maintain the lowest hash value of a row in which that column has a 1, indep endently for each of the 100 hash functions. After considering all rows, we shall have for each column the rst rows in which the column has 1, if the rows had b een p ermuted in the orders given by each of the 100 hash functions.
Problem: we've got signatures for all the columns in main memory, and similar signatures mean similar columns, with high probability, but there still may b e so many columns that doing anything that is quadratic in the numb er of columns, even in main memory, is prohibitive. Locality-sensitive hashing (LSH) is a technique to b e used in main memory for approximating the set of similar column-pairs with a lot less than quadratic work. The goal: in time prop ortional to the numb er of columns, eliminate as p ossible similar pairs the vast ma jority of the column pairs.
The argument is that all 100 rows of S ig 1 are in the union. In addition, those rows of S ig 2 that are not rows of S ig 1 are in the union, and the latter set of rows is on average 100 c=(a + c) rows. Thus, the similarity of S ig 1 and S ig 2 is: jS ig 1 \ S ig 2 j jS ig 1 [ S ig 2 j
100 a a+c 100 + (^100) a+cc
a a + 2 c
Note that if c is close to b, then the similarity of the signatures is close to the similarity of the columns, which is a=(a + b + c). In fact, if the columns are very similar, then b and c are b oth small compared to a, and the similarities of the signatures and columns must b e close.
If columns are not sparse, but have ab out 50% 1's, then we don't need min-hashing; a random collection of rows serves as a signature. Hamming LSH constructs a series of matrices, each with half as many rows as the previous, by OR-ing together two consecutive rows from the previous, as in Fig. 5.
Figure 5: Construction of a series of exp onentially smaller, denser matrices
There are no more than log n matrices if n is the numb er of rows. The total numb er of rows in all matrices is 2 n, and they can all b e computed with one pass through the original matrix, storing the large ones on disk.
In each matrix, pro duce as candidate pairs those columns that:
Note that the density range 20{80% guarantees that any two columns that are at least 50% similar will b e considered together in at least one matrix, unless by bad luck their relative densities change due to the OR op eration combining two 1's into one.
A second pass through the original data con rms which of the candidates are really similar.
This metho d exploits an idea that can b e useful elsewhere: similar columns have similar numb ers of 1's, so there is no p oint ever comparing columns whose numb ers of 1's are very di erent.