comparison python/utils.py @ 376:2e6b8610bcaa

work on indicator similarity
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 17 Jul 2013 18:19:08 -0400
parents 2ea8584aa80a
children 387cc0142211
comparison
equal deleted inserted replaced
375:2ea8584aa80a 376:2e6b8610bcaa
291 291
292 def computeAlignment(self): 292 def computeAlignment(self):
293 from numpy import mean 293 from numpy import mean
294 return mean([j-i for i,j in self.subSequenceIndices]) 294 return mean([j-i for i,j in self.subSequenceIndices])
295 295
296 def _computeNormalized(self, l1, l2): 296 def _computeNormalized(self, l1, l2, computeSubSequence = False):
297 ''' compute the normalized LCSS 297 ''' compute the normalized LCSS
298 ie, the LCSS divided by the min or mean of the indicator lengths (using lengthFunc) 298 ie, the LCSS divided by the min or mean of the indicator lengths (using lengthFunc)
299 lengthFunc = lambda x,y:float(x,y)/2''' 299 lengthFunc = lambda x,y:float(x,y)/2'''
300 return float(self._compute(l1, l2))/self.lengthFunc(len(l1), len(l2)) 300 return float(self._compute(l1, l2, computeSubSequence))/self.lengthFunc(len(l1), len(l2))
301 301
302 def computeNormalized(self, l1, l2): 302 def computeNormalized(self, l1, l2, computeSubSequence = False):
303 return self._computeNormalized(l1, l2) 303 return self._computeNormalized(l1, l2, computeSubSequence)
304 304
305 def _computeDistance(self, l1, l2): 305 def _computeDistance(self, l1, l2, computeSubSequence = False):
306 ''' compute the LCSS distance''' 306 ''' compute the LCSS distance'''
307 return 1-self._computeNormalized(l1, l2) 307 return 1-self._computeNormalized(l1, l2, computeSubSequence)
308 308
309 def computeDistance(self, l1, l2): 309 def computeDistance(self, l1, l2, computeSubSequence = False):
310 return self._computeDistance(l1, l2) 310 return self._computeDistance(l1, l2, computeSubSequence)
311 311
312 ######################### 312 #########################
313 # plotting section 313 # plotting section
314 ######################### 314 #########################
315 315