handling large data on single computer creating hash function the hash functions we create take the values of movies for customer we decided in the theory part of this case study to create hash functionsthe first function combines the movies and the second combines movies and and the third one combines and it' up to you if you want to pick othersthis can be picked randomly the following code listing shows how this is done listing creating hash functions define hash function (it is exactly like the createnum(function without the final conversion to number and for columns instead of def hash_fn( , , )return [ '% % % ( , ,kfor ( , ,kin zip( , , )assert hash_fn([ , ],[ , ],[ , ]=[ ' ', ' 'test if it works correctly (if no error is raisedit worksit' sampling on columns but all observations will be selected store['bucket 'hash_fn(data movie data movie ,data movie store['bucket 'hash_fn(data movie data movie ,data movie store['bucket 'hash_fn(data movie data movie ,data movie store to_sql('movie_comparison',mcflavor 'mysql'index trueindex_label 'cust_id'if_exists 'replace'store this information in database create hash values from customer moviesrespectively [ , ][ , ][ , the hash function concatenates the values from the different movies into binary value like what happened before in the createnum(functiononly this time we don' convert to numbers and we only take movies instead of as input the assert function shows how it concatenates the values for every observation when the client has bought movie but not movies and it will return ' for bucket when the client bought movies and but not it will return ' for bucket if we look at the current result we see the variables we created earlier (bit bit bit bit from the handpicked movies (figure figure information from the bit string compression and the sampled movies the last trick we'll apply is indexing the customer table so lookups happen more quickly