Mercurial Hosting > traffic-intelligence
comparison python/indicators.py @ 312:6c068047edbf
merged with Mohamed s work
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Thu, 11 Apr 2013 22:46:33 -0400 |
parents | 93d851d0d21e 8bafd054cda4 |
children | 43e62b9cb652 |
comparison
equal
deleted
inserted
replaced
311:273c200ec32e | 312:6c068047edbf |
---|---|
91 marker = '' | 91 marker = '' |
92 time = sorted(self.values.keys()) | 92 time = sorted(self.values.keys()) |
93 plot([x/xfactor for x in time], [self.values[i] for i in time], options+marker, **kwargs) | 93 plot([x/xfactor for x in time], [self.values[i] for i in time], options+marker, **kwargs) |
94 if self.maxValue: | 94 if self.maxValue: |
95 ylim(ymax = self.maxValue) | 95 ylim(ymax = self.maxValue) |
96 | |
97 def valueSorted(self): | |
98 ''' return the values after sort the keys in the indicator | |
99 This should probably not be used: to delete''' | |
100 values=[] | |
101 keys = self.values.keys() | |
102 keys.sort() | |
103 for key in keys: | |
104 values.append(self.values[key]) | |
105 return values | |
106 | |
107 @staticmethod | |
108 def getDLCSS(TemporalIndicator1,TemporalIndicator2, threshold, delta= np.inf , method='min' ): | |
109 ''' compute the distance between two indicators using LCSS | |
110 two common methods are used: min or mean of the indicators length''' | |
111 l1= TemporalIndicator1.valueSorted | |
112 l2= TemporalIndicator2.valueSorted | |
113 if method = 'min': | |
114 DLCSS= 1- (LCSS(l1,l2, threshold, delta, distance))/min(len(l1),len(l2))) | |
115 if method = 'mean': | |
116 average= len(l1)+len(l2))/2 | |
117 DLCSS= 1- ((LCSS(l1,l2, threshold, delta, distance))/average) | |
118 return DLCSS | |
119 | |
96 | 120 |
97 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): | 121 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): |
98 ''' compute the distance between two indicators using LCSS | 122 ''' compute the distance between two indicators using LCSS |
99 two common methods are used: min or mean of the indicators length''' | 123 two common methods are used: min or mean of the indicators length''' |
100 from utils import LCSS | 124 from utils import LCSS |