In [85]:
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression, Ridge, Lasso
from sklearn.preprocessing import StandardScaler
from sklearn.decomposition import NMF
import matplotlib.pyplot as plt
%matplotlib inline

Exercise 4 - Locality Sensitive Hashing


In [2]:
for b in range(1, 30):
    for r in range(1, 20):
        if 1-(1-0.95**r)**b >= 0.99 and 1-(1-0.80**r)**b <= 0.15:
            print('r=', r, 'b=', b, 'k=', r*b)


('r=', 19, 'b=', 10, 'k=', 190)
('r=', 19, 'b=', 11, 'k=', 209)

In [5]:
from ipywidgets import interact
%matplotlib notebook
import numpy as np
t = np.linspace(0, 1, 100)
r = 100
s = 1-(1-t**r)**(np.log(1-0.9)/np.log(1-0.9**r))
f = 1 - (1-t**r)**b
import matplotlib.pyplot as plt
%matplotlib notebook
plt.plot(t, s)
print(s)


[  0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
   0.00000000e+00   1.92486027e-11   7.69944108e-11   3.17601945e-10
   1.28003208e-09   5.09125531e-09   1.98453090e-08   7.59549823e-08
   2.85629971e-07   1.05563130e-06   3.83618136e-06   1.37134188e-05
   4.82422727e-05   1.67072563e-04   5.69771867e-04   1.91351959e-03
   6.32399139e-03   2.05041237e-02   6.45470422e-02   1.91046932e-01
   4.85637298e-01   8.72290847e-01   9.98146732e-01   9.99999994e-01
   1.00000000e+00   1.00000000e+00   1.00000000e+00   1.00000000e+00
   1.00000000e+00   1.00000000e+00   1.00000000e+00   1.00000000e+00]

In [ ]: