comparison scripts/performance-lcss.py @ 1012:01db14e947e4

resolved
author Wendlasida
date Fri, 01 Jun 2018 10:47:49 -0400
parents 933670761a57
children
comparison
equal deleted inserted replaced
1011:4f0312bee393 1012:01db14e947e4
1 #! /usr/bin/env python 1 #! /usr/bin/env python3
2 2
3 import timeit 3 import timeit
4 4
5 vectorLength = 10 5 vectorLength = 10
6 number = 10 6 number = 10
7 7
8 print('Default Python implementation with lambda') 8 print('Default Python implementation with lambda')
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) 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))
10 10
11 print('Using scipy distance.cdist') 11 print('Using scipy distance.cdist')
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) 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))