示例#1
0
 def closest(i, arr):
     """
 :param arr: np array (len=No. Indep var + No. Depen var)
 :return: float
 """
     return sorted(i.clstr,
                   key=lambda x: edist(arr.sample[:-1], x.sample[:-1]))
示例#2
0
文件: strawman.py 项目: ai-se/RAAT
 def envy(self, testCase, alpha=0.5):
   me = self.closest(testCase)
   others = [o for o in self.clusters if not me == o]
   betters = [f for f in others if f.exemplar()[-1] < alpha*me.exemplar()[-1]]
   try:
     return sorted([f for f in betters],
                   key=lambda F: edist(F.exemplar()/self.norm, me.exemplar()/self.norm))[0]
   except:
     return me
示例#3
0
文件: CD.py 项目: ai-se/RAAT
 def closest(i, arr):
   """
   :param arr: np array (len=No. Indep var + No. Depen var)
   :return: float
   """
   return sorted(i.clstr, key= lambda x: edist(arr[:-1], x.sample[:-1]))
示例#4
0
文件: CD.py 项目: ai-se/RAAT
 def proj(one, two, test):
   a = edist(one, test)
   b = edist(two, test)
   c = edist(one, two)
   return (a**2-b**2+c**2)/(2*c)
示例#5
0
 def proj(one, two, test):
     a = edist(one, test)
     b = edist(two, test)
     c = edist(one, two)
     return (a**2 - b**2 + c**2) / (2 * c)
示例#6
0
文件: strawman.py 项目: ai-se/RAAT
 def closest(self, testCase):
   return sorted([f for f in self.clusters],
                 key=lambda F: edist(F.exemplar(), testCase[:-1]))[0]