-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGuesser.py
More file actions
56 lines (43 loc) · 1.4 KB
/
Copy pathGuesser.py
File metadata and controls
56 lines (43 loc) · 1.4 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
__author__ = 'Khaleeq'
from GlobalDb import *
import numpy as np
def middle(nums):
nums.sort()
length = len(nums)
half = length//2
# if length % 2: #if even, return the half
# print half #TODO LOG THIS
return nums[half]
# else: #if odd
# return (nums[half] + nums[half-1] )/2
def topObjects(d, nots):
tops = d.copy()
# limit = int(np.mean(tops.values()))
limit = int(np.percentile(d.values(), 75))
for o in tops.keys():
if (int(tops.get(o)) < limit):# or (o in nots):
del tops[o]
# if (len(d) > 0): #and (o in nots):
# del d[o]
# print str(nots)+"::NOTS"
# print str((limit)) +":"+ str(len(tops))
if len(tops) > 0:
return tops
else:
return d
def modifyScore(d, key, value):
if key in d.keys():
if isinstance( value, ( int, long, float ) ):
d[key] = d.get(key) + value
# print "\t :" + key + " +" + str(value) + "\t : "+ str(d.get(key))
def removeObject(d, key):
del d[key]
print "\t :" + key + " X"
def getEffected(objects, question, all_features):
effected = all_features[question]['concepts']
# intersection = effected.viewkeys() & objects.viewkeys()
# for o in effected.keys():
# if not (o in intersection):
# del effected[o]
# print effected.keys()
return effected