-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverlap.py
32 lines (31 loc) · 983 Bytes
/
Overlap.py
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
from .Measure import *
import timeit
class Overlap(Measure):
def __init__(self):
self.name = "Overlap"
def calculate(self, instance1, instance2):
distance = 0
length = len(instance1)
for x in range(length):
distance =distance+self.distMatrix[x][instance1[x]][instance2[x]]
distance/= length
if distance==0: distance= 0.000001
return distance
def setUp(self, X, y):
start = timeit.default_timer()
self.X_ = X
self.N = len(self.X_[:, 0])
self.max = []
for i in range(len(X[0])):
self.max.append(max(X[:,i]))
D = len(X[0])
self.distMatrix = [];
if self.LoaddistMatrixAuto()==False:
self.GeneratedistMatrix()
self.SavedistMatrix()
return timeit.default_timer()- start
def CalcdistanceArrayForDimension(self,k,xi,xj):
if xi == xj:
return 0
else:
return 1