annotate scripts/performance-lcss.py @ 1208:a07e455baaa6

merged
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 26 Apr 2023 18:33:46 -0400
parents 933670761a57
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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))