Mercurial Hosting > traffic-intelligence
comparison python/indicators.py @ 316:c5518a35df5f
merged
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 12 Apr 2013 15:22:00 -0400 |
parents | 43e62b9cb652 |
children | a5e40bd04cf4 |
comparison
equal
deleted
inserted
replaced
315:82b9be447608 | 316:c5518a35df5f |
---|---|
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(indic1, indic2, threshold, delta = float('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 = indic1.valueSorted | |
112 l2 = indic2.valueSorted | |
113 DLCSS = None | |
114 if method == 'min': | |
115 DLCSS = 1- (LCSS(l1,l2, threshold, delta, distance))/min(len(l1),len(l2)) | |
116 if method == 'mean': | |
117 average = len(l1)+len(l2)/2 | |
118 DLCSS = 1- ((LCSS(l1,l2, threshold, delta, distance))/average) | |
119 return DLCSS | |
120 | |
96 | 121 |
97 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): | 122 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): |
98 ''' compute the distance between two indicators using LCSS | 123 ''' compute the distance between two indicators using LCSS |
99 two common methods are used: min or mean of the indicators length''' | 124 two common methods are used: min or mean of the indicators length''' |
100 from utils import LCSS | 125 from utils import LCSS |