-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathqueryutils.py
More file actions
31 lines (22 loc) · 798 Bytes
/
queryutils.py
File metadata and controls
31 lines (22 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def topk(k, data, q, verbose=False):
df = data.copy(deep=True)
df['S(r)'] = q.dot(df.T)
df = df.sort_values(by=['S(r)'], ascending=True)
if verbose:
print("Executed top{} query with params={}".format(k, q))
return df[:k]
def evaluateDominance(data, p_i, dims=2):
dominators = []
dominees = []
incomp = []
p = data.loc[p_i]
for idx, r in data.iterrows():
if idx == p_i:
continue
if all([r[d] <= p[d] for d in range(dims)]) and any([r[d] < p[d] for d in range(dims)]):
dominators.append(r)
elif all([p[d] <= r[d] for d in range(dims)]) and any([p[d] < r[d] for d in range(dims)]):
dominees.append(r)
else:
incomp.append(r)
return dominators, dominees, incomp