MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / __init__

Method __init__

join/LSH/datasketch/lshensemble.py:65–96  ·  view source on GitHub ↗
(self, threshold=0.9, num_perm=128, num_part=16, m=8,
            weights=(0.5,0.5), storage_config=None, prepickle=None)

Source from the content-addressed store, hash-verified

63 '''
64
65 def __init__(self, threshold=0.9, num_perm=128, num_part=16, m=8,
66 weights=(0.5,0.5), storage_config=None, prepickle=None):
67 if threshold > 1.0 or threshold < 0.0:
68 raise ValueError("threshold must be in [0.0, 1.0]")
69 if num_perm < 2:
70 raise ValueError("Too few permutation functions")
71 if num_part < 1:
72 raise ValueError("num_part must be at least 1")
73 if m < 2 or m > num_perm:
74 raise ValueError("m must be in the range of [2, num_perm]")
75 if any(w < 0.0 or w > 1.0 for w in weights):
76 raise ValueError("Weight must be in [0.0, 1.0]")
77 if sum(weights) != 1.0:
78 raise ValueError("Weights must sum to 1.0")
79 self.threshold = threshold
80 self.h = num_perm
81 self.m = m
82 rs = self._init_optimal_params(weights)
83 # 对于r的每个可能取值,对LSHEnsemble中每个分区初始化一个LSH,索引初始化完成
84 storage_config = {'type': 'dict'} if not storage_config else storage_config
85 basename = storage_config.get('basename', _random_name(11))
86 self.indexes = [
87 dict((r, MinHashLSH(
88 num_perm=self.h,
89 params=(int(self.h/r), r),
90 # 不同的分区存储方式可能不同
91 storage_config=self._get_storage_config(
92 basename, storage_config, partition, r),
93 prepickle=prepickle)) for r in rs)
94 for partition in range(0, num_part)]
95 self.lowers = [None for _ in self.indexes]
96 self.uppers = [None for _ in self.indexes]
97
98 # 给出一系列可能存在的xq,预处理得到使fp和fn带权和最优的参数b与r
99 def _init_optimal_params(self, weights):

Callers

nothing calls this directly

Calls 5

_init_optimal_paramsMethod · 0.95
_get_storage_configMethod · 0.95
_random_nameFunction · 0.90
MinHashLSHClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected