Mercurial Hosting > traffic-intelligence
annotate trafficintelligence/tests/utils.txt @ 1280:2abeccdbb985 default tip
removing print debug
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Wed, 03 Jul 2024 15:13:15 -0400 |
parents | 7493751bfe19 |
children |
rev | line source |
---|---|
1030
aafbc0bab925
moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1028
diff
changeset
|
1 >>> from trafficintelligence.utils import * |
aafbc0bab925
moved method around to avoid cross-dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1028
diff
changeset
|
2 >>> from trafficintelligence.moving import Point |
1250
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
3 >>> from numpy import array, arange |
31
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
4 |
742
fe71639f1ee7
merge and added function to up-/lower-case strings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
733
diff
changeset
|
5 >>> upperCaseFirstLetter('mmmm... donuts') |
743
4b3518f6dd01
tests for upperCaseFirstLetter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
742
diff
changeset
|
6 'Mmmm... Donuts' |
4b3518f6dd01
tests for upperCaseFirstLetter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
742
diff
changeset
|
7 >>> s = upperCaseFirstLetter('much ado about nothing') |
4b3518f6dd01
tests for upperCaseFirstLetter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
742
diff
changeset
|
8 >>> s == 'Much Ado About Nothing' |
4b3518f6dd01
tests for upperCaseFirstLetter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
742
diff
changeset
|
9 True |
4b3518f6dd01
tests for upperCaseFirstLetter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
742
diff
changeset
|
10 >>> upperCaseFirstLetter(s) == s |
4b3518f6dd01
tests for upperCaseFirstLetter
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
742
diff
changeset
|
11 True |
742
fe71639f1ee7
merge and added function to up-/lower-case strings
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
733
diff
changeset
|
12 |
31
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
13 >>> computeChi2([],[]) |
878
8e8ec4ece66e
minor + bug corrected in motion pattern learning
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
743
diff
changeset
|
14 0 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
15 >>> computeChi2(list(range(1,10)),list(range(1,10))) |
31
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
16 0.0 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
17 >>> computeChi2(list(range(1,9)),list(range(1,10))) |
31
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
18 0.0 |
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
19 |
32 | 20 >>> ceilDecimals(1.23, 0) |
21 2.0 | |
22 >>> ceilDecimals(1.23, 1) | |
23 1.3 | |
24 | |
152
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
42
diff
changeset
|
25 >>> inBetween(1,2,1.5) |
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
42
diff
changeset
|
26 True |
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
42
diff
changeset
|
27 >>> inBetween(2.1,1,1.5) |
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
42
diff
changeset
|
28 True |
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
42
diff
changeset
|
29 >>> inBetween(1,2,0) |
74b1fc68d4df
re-organized code to avoid cyclic python module dependencies
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
42
diff
changeset
|
30 False |
31
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
31 |
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
32 >>> removeExtension('test-adfasdf.asdfa.txt') |
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
33 'test-adfasdf.asdfa' |
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
34 >>> removeExtension('test-adfasdf') |
c000f37c316d
moved tests to independent file, added chi2 computation
Nicolas Saunier <nico@confins.net>
parents:
diff
changeset
|
35 'test-adfasdf' |
42
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
36 |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
37 >>> values = line2Ints('1 2 3 5 6') |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
38 >>> values[0] |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
39 1 |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
40 >>> values[-1] |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
41 6 |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
42 >>> values = line2Floats('1.3 2.45 7.158e+01 5 6') |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
43 >>> values[0] |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
44 1.3 |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
45 >>> values[2] #doctest: +ELLIPSIS |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
46 71.5... |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
47 >>> values[-1] |
1a2ac2d4f53a
added loading of the rest of the data for objects
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
32
diff
changeset
|
48 6.0 |
285
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
49 |
1276
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
50 >>> filterCategoricalMovingWindow([3]*3 + [4]*4, 2) |
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
51 [3, 3, 3, 4, 4, 4, 4] |
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
52 >>> filterCategoricalMovingWindow([3]*6 + [4], 2) |
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
53 [3, 3, 3, 3, 3, 3, 3] |
1277
7493751bfe19
update to test as it seems non deterministic
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1276
diff
changeset
|
54 >>> 'c' in filterCategoricalMovingWindow(['a']*3 + ['c'] + ['b']*3, 2) |
7493751bfe19
update to test as it seems non deterministic
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1276
diff
changeset
|
55 False |
1276
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
56 >>> filterCategoricalMovingWindow([3], 2) |
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
57 [3] |
bae8de98406f
corrected bug in categorical value smoothing
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1250
diff
changeset
|
58 |
1250
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
59 >>> filterMovingWindow(arange(10), 3) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
60 array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
61 >>> filterMovingWindow(list(range(10)), 3) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
62 array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
63 >>> filterMovingWindow(arange(10.), 3) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
64 array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
65 >>> filterMovingWindow(arange(10.), 2) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
66 array([0., 1., 2., 3., 4., 5., 6., 7., 8., 9.]) |
77fbd0e2ba7d
dltrack works with moving average filtering
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1034
diff
changeset
|
67 |
297
f6f423e25c7f
adding function to generate step plots (for cumulative number of vehicles)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
285
diff
changeset
|
68 >>> stepPlot([3, 5, 7, 8], 1, 10, 0) |
f6f423e25c7f
adding function to generate step plots (for cumulative number of vehicles)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
285
diff
changeset
|
69 ([1, 3, 3, 5, 5, 7, 7, 8, 8, 10], [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) |
f6f423e25c7f
adding function to generate step plots (for cumulative number of vehicles)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
285
diff
changeset
|
70 |
455
abe0b2347d4c
added most common utility function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
374
diff
changeset
|
71 >>> mostCommon(['a','b','c','b']) |
abe0b2347d4c
added most common utility function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
374
diff
changeset
|
72 'b' |
abe0b2347d4c
added most common utility function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
374
diff
changeset
|
73 >>> mostCommon(['a','b','c','b', 'c']) |
abe0b2347d4c
added most common utility function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
374
diff
changeset
|
74 'b' |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
75 >>> mostCommon(list(range(10))+[1]) |
455
abe0b2347d4c
added most common utility function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
374
diff
changeset
|
76 1 |
1034
4069d8545922
updated mostCommong function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
77 >>> mostCommon([(1,2), (2,3), (1,2)]) |
4069d8545922
updated mostCommong function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
1030
diff
changeset
|
78 (1, 2) |
455
abe0b2347d4c
added most common utility function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
374
diff
changeset
|
79 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
80 >>> res = sortByLength([list(range(3)), list(range(4)), list(range(1))]) |
733 | 81 >>> [len(r) for r in res] |
82 [1, 3, 4] | |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
83 >>> res = sortByLength([list(range(3)), list(range(4)), list(range(1)), list(range(5))], reverse = True) |
733 | 84 >>> [len(r) for r in res] |
85 [5, 4, 3, 1] | |
86 | |
689
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
87 >>> lcss = LCSS(similarityFunc = lambda x,y: abs(x-y) <= 0.1) |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
88 >>> lcss.compute(list(range(5)), list(range(5))) |
285
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
89 5 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
90 >>> lcss.compute(list(range(1,5)), list(range(5))) |
285
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
91 4 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
92 >>> lcss.compute(list(range(5,10)), list(range(5))) |
285
5957aa1d69e1
Integrating Mohamed's changes
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
152
diff
changeset
|
93 0 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
94 >>> lcss.compute(list(range(5)), list(range(10))) |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
297
diff
changeset
|
95 5 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
96 >>> lcss.similarityFunc = lambda x,y: x == y |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
97 >>> lcss.compute(['a','b','c'], ['a','b','c', 'd']) |
366
90bdabc06e9f
updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
323
diff
changeset
|
98 3 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
99 >>> lcss.computeNormalized(['a','b','c'], ['a','b','c', 'd']) #doctest: +ELLIPSIS |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
100 1.0 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
101 >>> lcss.computeNormalized(['a','b','c','x'], ['a','b','c', 'd']) #doctest: +ELLIPSIS |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
102 0.75 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
103 >>> lcss.compute(['a','b','c'], ['a','b','c', 'd']) |
366
90bdabc06e9f
updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
323
diff
changeset
|
104 3 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
105 >>> lcss.compute(['a','x','b','c'], ['a','b','c','d','x']) |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
106 3 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
107 >>> lcss.compute(['a','b','c','x','d'], ['a','b','c','d','x']) |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
297
diff
changeset
|
108 4 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
109 >>> lcss.delta = 1 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
110 >>> lcss.compute(['a','b','c'], ['a','b','x','x','c']) |
368
2db4e76599a1
implemented subsequence extraction and rearranged arguments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
366
diff
changeset
|
111 2 |
2db4e76599a1
implemented subsequence extraction and rearranged arguments
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
366
diff
changeset
|
112 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
113 >>> lcss.delta = float('inf') |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
114 >>> lcss.compute(['a','b','c'], ['a','b','c', 'd'], computeSubSequence = True) |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
115 3 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
116 >>> lcss.subSequenceIndices |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
117 [(0, 0), (1, 1), (2, 2)] |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
118 >>> lcss.compute(['a','b','c'], ['x','a','b','c'], computeSubSequence = True) |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
119 3 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
120 >>> lcss.subSequenceIndices |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
121 [(0, 1), (1, 2), (2, 3)] |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
122 >>> lcss.compute(['a','g','b','c'], ['a','b','c', 'd'], computeSubSequence = True) |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
123 3 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
124 >>> lcss.subSequenceIndices |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
125 [(0, 0), (2, 1), (3, 2)] |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
297
diff
changeset
|
126 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
127 >>> alignedLcss = LCSS(lambda x,y:(abs(x-y) <= 0.1), delta = 2, aligned = True) |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
128 >>> alignedLcss.compute(list(range(5)), list(range(5))) |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
297
diff
changeset
|
129 5 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
130 >>> alignedLcss.compute(list(range(1,5)), list(range(5))) |
366
90bdabc06e9f
updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
323
diff
changeset
|
131 4 |
90bdabc06e9f
updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
323
diff
changeset
|
132 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
133 >>> alignedLcss.compute(list(range(5,10)), list(range(10))) |
366
90bdabc06e9f
updated LCSS to be more generic with a single similarity function
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
323
diff
changeset
|
134 5 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
135 |
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
136 >>> lcss.delta = 2 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
137 >>> lcss.compute(list(range(5,10)), list(range(10))) |
322
28661c5887d3
Corrected a major bug for LCSS
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
297
diff
changeset
|
138 0 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
139 >>> alignedLcss.delta = 6 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
140 >>> alignedLcss.compute(list(range(5)), list(range(5))) |
323
efd4dd4665ac
corrected issues with large deltas
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
322
diff
changeset
|
141 5 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
142 >>> alignedLcss.compute(list(range(5)), list(range(6))) |
323
efd4dd4665ac
corrected issues with large deltas
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
322
diff
changeset
|
143 5 |
369
027e254f0b53
lcss subclass for indicators
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
368
diff
changeset
|
144 >>> lcss.delta = 10 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
145 >>> alignedLcss.compute(list(range(1,7)), list(range(6))) |
323
efd4dd4665ac
corrected issues with large deltas
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
322
diff
changeset
|
146 5 |
374
a7af3519687e
finished implementation of aligned LCSS with matching sequence decoded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
369
diff
changeset
|
147 >>> lcss = LCSS(lambda x,y: x == y, delta = 2, aligned = True) |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
148 >>> lcss.compute(list(range(20)), [2,4,6,7,8,9,11,13], True) |
374
a7af3519687e
finished implementation of aligned LCSS with matching sequence decoded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
369
diff
changeset
|
149 8 |
a7af3519687e
finished implementation of aligned LCSS with matching sequence decoded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
369
diff
changeset
|
150 >>> lcss.subSequenceIndices |
a7af3519687e
finished implementation of aligned LCSS with matching sequence decoded
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
369
diff
changeset
|
151 [(2, 0), (4, 1), (6, 2), (7, 3), (8, 4), (9, 5), (11, 6), (13, 7)] |
689
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
152 |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
153 >>> lcss = LCSS(metric = 'cityblock', epsilon = 0.1) |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
154 >>> lcss.compute([[i] for i in range(5)], [[i] for i in range(5)]) |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
155 5 |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
156 >>> lcss.compute([[i] for i in range(1,5)], [[i] for i in range(5)]) |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
157 4 |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
158 >>> lcss.compute([[i] for i in range(5,10)], [[i] for i in range(5)]) |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
159 0 |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
160 >>> lcss.compute([[i] for i in range(5)], [[i] for i in range(10)]) |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
161 5 |
9990ef119bce
added version of LCSS with cdist computations
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
516
diff
changeset
|
162 |
997
4f3387a242a1
updated utils to python 3
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
878
diff
changeset
|
163 |