# HG changeset patch # User Nicolas Saunier # Date 1365734793 14400 # Node ID 6c068047edbfee0d96f3b28faa7f6b881799e3b8 # Parent 273c200ec32e9959ba90f46823f836e1dd041c91# Parent 80cbafd6910935582f1574a1128a18e8f4d83169 merged with Mohamed s work diff -r 273c200ec32e -r 6c068047edbf python/indicators.py --- a/python/indicators.py Wed Apr 03 22:46:39 2013 -0400 +++ b/python/indicators.py Thu Apr 11 22:46:33 2013 -0400 @@ -93,6 +93,30 @@ plot([x/xfactor for x in time], [self.values[i] for i in time], options+marker, **kwargs) if self.maxValue: ylim(ymax = self.maxValue) + + def valueSorted(self): + ''' return the values after sort the keys in the indicator + This should probably not be used: to delete''' + values=[] + keys = self.values.keys() + keys.sort() + for key in keys: + values.append(self.values[key]) + return values + + @staticmethod + def getDLCSS(TemporalIndicator1,TemporalIndicator2, threshold, delta= np.inf , method='min' ): + ''' compute the distance between two indicators using LCSS + two common methods are used: min or mean of the indicators length''' + l1= TemporalIndicator1.valueSorted + l2= TemporalIndicator2.valueSorted + if method = 'min': + DLCSS= 1- (LCSS(l1,l2, threshold, delta, distance))/min(len(l1),len(l2))) + if method = 'mean': + average= len(l1)+len(l2))/2 + DLCSS= 1- ((LCSS(l1,l2, threshold, delta, distance))/average) + return DLCSS + def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): ''' compute the distance between two indicators using LCSS diff -r 273c200ec32e -r 6c068047edbf python/ml.py diff -r 273c200ec32e -r 6c068047edbf python/utils.py