Mercurial > hg > nsaunier > traffic-intelligence
comparison python/indicators.py @ 313:43e62b9cb652
solved issues to make the files importable (caution with getDLCSS)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Thu, 11 Apr 2013 22:50:04 -0400 |
| parents | 6c068047edbf |
| children | a5e40bd04cf4 |
comparison
equal
deleted
inserted
replaced
| 312:6c068047edbf | 313:43e62b9cb652 |
|---|---|
| 103 for key in keys: | 103 for key in keys: |
| 104 values.append(self.values[key]) | 104 values.append(self.values[key]) |
| 105 return values | 105 return values |
| 106 | 106 |
| 107 @staticmethod | 107 @staticmethod |
| 108 def getDLCSS(TemporalIndicator1,TemporalIndicator2, threshold, delta= np.inf , method='min' ): | 108 def getDLCSS(indic1, indic2, threshold, delta = float('inf') , method ='min' ): |
| 109 ''' compute the distance between two indicators using LCSS | 109 ''' compute the distance between two indicators using LCSS |
| 110 two common methods are used: min or mean of the indicators length''' | 110 two common methods are used: min or mean of the indicators length''' |
| 111 l1= TemporalIndicator1.valueSorted | 111 l1 = indic1.valueSorted |
| 112 l2= TemporalIndicator2.valueSorted | 112 l2 = indic2.valueSorted |
| 113 if method = 'min': | 113 DLCSS = None |
| 114 DLCSS= 1- (LCSS(l1,l2, threshold, delta, distance))/min(len(l1),len(l2))) | 114 if method == 'min': |
| 115 if method = 'mean': | 115 DLCSS = 1- (LCSS(l1,l2, threshold, delta, distance))/min(len(l1),len(l2)) |
| 116 average= len(l1)+len(l2))/2 | 116 if method == 'mean': |
| 117 DLCSS= 1- ((LCSS(l1,l2, threshold, delta, distance))/average) | 117 average = len(l1)+len(l2)/2 |
| 118 return DLCSS | 118 DLCSS = 1- ((LCSS(l1,l2, threshold, delta, distance))/average) |
| 119 return DLCSS | |
| 119 | 120 |
| 120 | 121 |
| 121 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): | 122 def computeDLCSS(indicator1, indicator2, threshold, delta = float('inf'), method= 'min'): |
| 122 ''' compute the distance between two indicators using LCSS | 123 ''' compute the distance between two indicators using LCSS |
| 123 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''' |
