Mercurial Hosting > traffic-intelligence
changeset 312:6c068047edbf
merged with Mohamed s work
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 11 Apr 2013 22:46:33 -0400 |
parents | 273c200ec32e (current diff) 80cbafd69109 (diff) |
children | 43e62b9cb652 |
files | python/indicators.py python/ml.py python/utils.py |
diffstat | 1 files changed, 24 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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