human
Can you provide a the Python program you requested given the following:
I am working on the file "Mining massive datasets/algorithms.ipynb".
The first task is:
Min-hashing algorithm
Can you write Python program for it?
assistant
#Here is the Python program you requested.

import numpy as np

class MinHashing:
    def __init__(self, mat, hashfunc):
        self.matrix = mat
        self.m = len(mat)
        self.n = len(mat[0])
        self.hashfunc = hashfunc
        self.k = len(self.hashfunc)
    def minhash(self):
        self.sig = np.ones((self.k, self.n)) * 2 ** 10
        for j in range(self.m):
            for c in range(self.n):
                if self.matrix[j][c] == 1:
                    for i in range(self.k):
                        if self.hashfunc[i](j) < self.sig[i][c]:
                            self.sig[i][c] = self.hashfunc[i](j)
    def show(self):
        print self.sig

if __name__ == '__main__':
    hashfunc = [lambda x: (3 * x + 2) % 7, lambda x: (x - 1) % 7]
    mat = [[0,1],[1,0],[0,1],[0,0],[1,1],[1,1],[1,0]]
    mh = MinHashing(mat, hashfunc)
    mh.minhash()
    mh.show()

    # 2009 final
    mat = [[0,0,1],[1,1,1],[0,1,1],[1,0,0],[0,1,0]]
    hashfunc = [lambda x: x + 1, lambda x: (x - 1) % 5 + 1, lambda x: (x - 2) % 5 + 1, lambda x : (x - 3) % 5 + 1, lambda x: (x - 4) % 5 + 1]
    mh = MinHashing(mat, hashfunc)
    mh.minhash()
    mh.show()