Mercurial Hosting > traffic-intelligence
annotate scripts/performance-lcss.py @ 1163:fa9c358789ac
bug correction
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Fri, 19 Mar 2021 15:54:19 -0400 |
parents | 933670761a57 |
children |
rev | line source |
---|---|
998
933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
730
diff
changeset
|
1 #! /usr/bin/env python3 |
730
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
2 |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
3 import timeit |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
4 |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
5 vectorLength = 10 |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
6 number = 10 |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
7 |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
8 print('Default Python implementation with lambda') |
998
933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
730
diff
changeset
|
9 print(timeit.timeit('lcss.compute(random_sample(({},2)), random_sample(({}, 2)))'.format(vectorLength, vectorLength*2), setup = 'from utils import LCSS; from numpy.random import random_sample; lcss = LCSS(similarityFunc = lambda x,y: (abs(x[0]-y[0]) <= 0.1) and (abs(x[1]-y[1]) <= 0.1));', number = number)) |
730
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
10 |
a850a4f92735
added performance script comparing lcss using cdist with default
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff
changeset
|
11 print('Using scipy distance.cdist') |
998
933670761a57
updated code to python 3 (tests pass and scripts run, but non-executed parts of code are probably still not correct)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
730
diff
changeset
|
12 print(timeit.timeit('lcss.compute(random_sample(({},2)), random_sample(({}, 2)))'.format(vectorLength, vectorLength*2), setup = 'from utils import LCSS; from numpy.random import random_sample; lcss = LCSS(metric = "cityblock", epsilon = 0.1);', number = number)) |