view scripts/performance-lcss.py @ 1136:30171d4fd3df Tertuis-Ou-draogo/movingpy-issue-22-from-etienne-beauchamp-1584900380975

moving.py [Issue #22 from Etienne Beauchamp In annotationTool Correction]
author Tertuis Ouédraogo <tertuis95@gmail.com>
date Sun, 22 Mar 2020 18:06:22 +0000
parents 933670761a57
children
line wrap: on
line source

#! /usr/bin/env python3

import timeit

vectorLength = 10
number = 10

print('Default Python implementation with lambda')
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))

print('Using scipy distance.cdist')
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))