Mercurial > hg > nsaunier > traffic-intelligence
comparison python/ml.py @ 878:8e8ec4ece66e
minor + bug corrected in motion pattern learning
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 10 Mar 2017 15:31:26 -0500 |
| parents | 5dc7a507353e |
| children | 9fd7b18f75b4 |
comparison
equal
deleted
inserted
replaced
| 877:d1ff6917d082 | 878:8e8ec4ece66e |
|---|---|
| 148 and reassigning all elements in the cluster until no cluster is smaller than minClusterSize | 148 and reassigning all elements in the cluster until no cluster is smaller than minClusterSize |
| 149 | 149 |
| 150 TODO: at each step, optimize the prototype as the most similar in its current cluster (can be done easily if similarities are already computed)''' | 150 TODO: at each step, optimize the prototype as the most similar in its current cluster (can be done easily if similarities are already computed)''' |
| 151 | 151 |
| 152 # sort instances based on length | 152 # sort instances based on length |
| 153 if len(instances) == 0: | |
| 154 print('no instances to cluster (empty list)') | |
| 155 return None | |
| 156 | |
| 153 indices = range(len(instances)) | 157 indices = range(len(instances)) |
| 154 if randomInitialization: | 158 if randomInitialization: |
| 155 indices = np.random.permutation(indices) | 159 indices = np.random.permutation(indices) |
| 156 else: | 160 else: |
| 157 def compare(i, j): | 161 def compare(i, j): |
