ShapeTimeSeparation
Code for separating shape and temporal patterns in time series subsets
view repo
In this article we address the problem of separation of shape and time components in time series. The concept of shape that we tackle is termed temporally "neutral" to consider that it may possibly exist outside of any temporal specification, as it is the case for a geometric form. We propose to exploit and adapt a probabilistic temporal alignment algorithm, initially designed to estimate the centroid of a set of time series, to build some heuristic elements of solution to this separation problem. We show on some controlled synthetic data that this algorithm meets empirically our initial objectives. We finally evaluate it on real data, in the context of some on-line handwritten signature authentication benchmarks. On the three evaluated tasks, our approach based on the separation of signature shape and associated temporal patterns is positioned slightly above the current state of the art demonstrating the application benefit of this separating problem.
READ FULL TEXT VIEW PDFCode for separating shape and temporal patterns in time series subsets
Some time series are quite specific in a way that they describe shapes. This is the case, for instance, for a dynamical system reaching a limit cycle in its observable state space. The concept of shape could have, however several meanings, and consequently a shape can be characterized through different perspectives. With a mathematical point of view, geometrical shapes can be defined as the solution set of an ensemble of equations. Simple shapes such as ellipses or complex structure such as strange attractors or fractal sets are fully entering into this kind of conceptual definition for a shape. In such view, if the equations defining the shape are time independent, the shape is fully defined as a geometric object that exist outside any temporal specification. Shapes, in another hand, can also be described indirectly through parametric equations that provide multivariate time series somehow forming the contour of a shape. The parameter entering into such equations is generally, by convention, referred to as the time variable. Apart from such purely mathematical formalizations, shapes have been also early associated to visual patterns. This association has motivated considerable research work in machine vision to identify or recognize shape-object [Andreopoulos2013], from their contour, texture, colors, etc. Progressively, from this somehow restricted view that assimilates a shape to an identifiable visual stimuli, a wider range of shape characterization associated to other perceptual stimuli has emerged. The acoustic channel has thereby led to the definition of acoustic patterns, i.e. phonemes, characteristic noises, musical forms, etc., that share a lot of similarity with the visual shapes, at least in their definitions. Thereby, major works have been done, in particular in the speech recognition area, to model and identify shapes "encoded" in acoustic time series. Beyond the acoustic channel modelization, time series analysis has allows for the characterization of very general "temporal" shapes [NIENNATTRAKUL2012], just as images or videos processing has allowed for visual-shapes. Today, temporal, visual or visuo-temporal shape analysis find applications in any area of our digitized world.
We adopt in this article a more restrictive definition for shape, somehow closer to a geometrical or mathematical characterization, according to which a form can exist outside any temporal consideration. Let us consider formally the ellipse example that is completely defined by the following equation 1.
(1) |
The set of solutions in this equation completely and atemporaly defines an ellipse. However, as stated above, this shape can also be defined through a set of parametric equations (Eq. 2) that reintroduce a parameter, , which we call the temporal variable.
(2) |
In this second formulation, the time series and also completely define the ellipse shape. These function of can be understood as access functions to the elements of the set of solutions.
When this parameter is sampled, it can indeed be considered as an index allowing to enumerate the pairs that are solutions of the preceding equations and regrouped this time in a multiset , with and the sampling frequency. We can then assimilate the shape associated with the ellipse to the multiset .
Shapes that can be characterized in this way are relatively diverse and potentially complex. They emerge in particular in the asymptotic behaviors of some nonlinear dynamic systems, stationary or not, described by differential or difference equations, in the form of limit cycles or strange attractors like the fractal attractors of Rosler or Lorentz. We can suppose that these shapes may also emerge in some traces produced by nonstationary stochastic generative systems, but in a noisy or hidden way, since the shapes are in this case accessible through an observable which depends on the time variable.
Based on this notion of atemporal shape, we are interested in the problem of the extraction of the shape (that is assumed to be atemporal) and associated temporal functions, given a subset of time series assumed to be produced by a stochastic generative process.
In the second part of this paper, we formalize this problem of shape/time separation for a restrictive category of stochastic processes expressed in discrete time and detail the heuristic approach that we develop to solve this problem, conjecturing that it is NP-complete. The third part is devoted to an experiment which allows to evaluate initially the algorithmic solution developed on synthetic data that we fully control. In a second step we test our algorithm on real data as part of on-line signature authentication tasks. In the last conclusive section, we discuss our findings and the prospects that they suggest.
We consider the following class of stochastic generative processes that can be formalized in a parametric form:
(3) |
with the discrete time variable, a function, possibly stochastic, monotonously increasing with , a nonlinear function randomly drawn from , the observable output of the process at timestamps and
a Gaussian noise with zero mean and standard deviation
. We will denote such process .The set will characterize what we call the shape variability and the set the temporal variability.
Thus, if we observe distinct realizations of the previous generative process, we get a set of traces such that:
(4) |
with , and a Gaussian noise.
In the absence of a strictly atemporal shape, we will call (temporally) neutral shape associated to the process defined by Eq.4
the time series , where represents the mathematical expectation, and . For the neutral shape, the associated temporal function corresponds to the mathematical expectation of observed functions.
As an example, the stochastic process defined by
matrix defined in Eq. 5,
,
constraints on the parameters, ,
,
, where is the uniform law defined on interval , and
the additive Gaussian noise ,
belongs to the class of process, sets and being respectively defined by the constraints on and parameters.
(5) |
Here, and .
The neutral shape for this process is .
Given , observations assumed to be produced by a stochastic process class ,
Can we estimate , , and under the conditions that , , , and a Gaussian noise with zero mean?
Answering this question is to separate the neutral shape from the temporal functions. This separation makes it possible to consider the study of shape variability independently of temporal variability.
The general problem of separability as previously stated is under-constrained (or ill-posed) and, as such, probably does not admit a solution in the general case. On the other hand, we empirically show that the algorithm proposed in
[Marteau2019] that estimates an average time series of a set of time series using temporally elastic kernel provides a way to approximate the concept of neutral shape. Moreover, the probabilistic formalization of the temporal alignment mechanism that is suggested is particularly suited to address our separation problem.We present below the general concepts of this algorithm (for details, see [Marteau2019]) and show how it offers elements of answer to the previously stated problem of separability.
Unlike the dynamic time warping algorithm (DTW) [Sakoe71] which considers only the best alignment path to match pairs of time series, the time elastic kernels [CuturiVert2007, MarteauGibet2014] consider the sum of the alignment scores of all possible matching paths. The score assigned to a path is the result of the product of the local matching kernels evaluated along the path.
Let and be two time series (observations) with respective lengths and . The local kernel that quantifies the proximity of two samples and is in general an exponential kernel : . By interpreting this local kernel as a local probability function [Marteau2019], it is possible to consider the alignment of two time series as the mathematical expectation of the outputs generated by a stochastic finite state machinery.
The considered stochastic automata is a Hidden Markov process defined on a finite set of hidden states . Each state characterizes the alignment between two samples and , is assimilated to the initial state and as the final state.
The hidden variable (at step ) takes value in . The index follows one of the admissible alignment paths and takes value in . To take into account monotonic alignment constraints (as in DTW), we impose , and .
The a posteriori probability for the process to be in state at step , given the observed sequences et est , where
is the vector of parameters of the Hidden Markov Model. This
a posteriori probability is estimated through forward and backward recursions, and defined as follows is the probability for the process to be at state at step once the partial observation sequences are aligned.
is the probability of the alignment of the pair of partial sequences given the alignment process is at state at step .
The matching of any pair of samples and can then be interpreted as the probability of presence of the stochastic alignment automata on cell .
The marginal probability for the process to be at step in one of the states of the subset , being given the observations and , (that is, the probability for the process to visit at step one of the state of , or to be aligned with one of the samples in the series ) is given by:
(6) |
For all and , the conditional probability of visiting the state knowing the two series of observations, the parameter and the subset , in other words the probability that and are aligned given that is aligned with one of the samples of the series is:
(7) |
The mathematical expectation of alignments of samples in the series with the sample (given that is aligned by the automaton) and similarly the expectation of the time occurrences associated with the samples of the series aligned with are defined by:
(8) |
The previous mathematical expectations (Eq. 8) are the basis of the proposed procedure for estimating a time elastic centroid for a set of time series.
Let be a subset of time series, a reference time series ( can be initialized with the medoid of ). The centroid estimate of is defined by the tuple where is a time series of length and is the sequence of time occurrences associated to the sample of
(9) |
is in general a non-uniformly sampled time series: is the mathematical expectation of the time of occurrence for sample . If necessary, a uniform re-sampling can straightforwardly be used to get back to a uniformly sampled time series.
By successive iterations, i.e. by replacing the reference time series by the new centroid estimates evaluated at the end of each iteration, until no more improvement can be obtained (decrease in inertia), we get a final estimate of the centroid for .
It should be noted here that the underlying multiple alignment problem being NP-complete [WangJ1994] and characterized with an exponential complexity [Just99] with the size of , only sub-optimal heuristics allow to approach this notion of temporally elastic centroid for sets of more than tens of time series.
We conjecture that, at the end of the iterative process, as defined by the equations Eq.9 is an empirical estimator for the neutral shape associated to the set . Furthermore, equations 8 also provide access to temporal function estimators associated with the elements of . Thus, for , and the neutral shape estimated on , the estimate of the temporal function associated with is:
(10) |
In other words, each corresponds to the mathematical expectation of the alignment times of the samples of the series with the sample of the neutral form.
In terms of algorithmic complexity, this algorithm is in , that is to say quadratic with respect to the average size of the time series and therefore of the size of the neutral form, and linear with respect to the cardinal of .
We detail hereinafter two experiments in order to empirically support conjecture and to illustrate how the algorithm operates. The meta parameter of the local kernel is automatically optimized on the learning data, such as avoiding the convergences to zero of the calculated probabilities.
We take again the ellipse example, previously introduced in subsection II-A, and characterized by the process defined through equation 5 with the following parameter values: with and the sampling frequency, , , , all the ellipses being centered in , a Gaussian noise with standard deviation .
A subset of time series is produced by from which the separation of shape and time functions is evaluated. The results of the separation process are shown in Fig. 1.
To illustrate the variability of (non-noisy) shapes produced by , the sub-figure at the top left shows the projections of the 20 ellipses randomly generated by . At the bottom right sub-figure, are presented i) the noisy trajectories of the time series produced by (cyan curves), the theoretical neutral (mean) shape (dashed red curve) and the neutral shape estimate (black curve) provided by our algorithm.
At the top center, the sub-figure presents the temporal variability by displaying the 20 true temporal functions associated with the previous shapes. The sub-figure at the bottom center shows the estimated temporal functions , the red curve corresponding to the mean time curve associated with the neutral shape.
Finally, the right sub-figures present new temporal functions produced by that violate the temporal constraints previously fixed. The true temporal functions are shown in the top sub-figure, while the estimated temporal function are shown in the bottom sub-figure. The red curve corresponds to the neutral temporal curve associated to the neutral shape (). The cyan color curve corresponds to the estimate of a function generated with a frequency that is twice higher than (). The shape is thus traveled twice as fast and the slope expected for the cyan curve is twice times lower than that of the red curve, which is approximately the case for the estimation displayed in the figure. The black curve corresponds to the estimate of a function generated with a frequency twice as small as (). The shape is therefore traveled half as fast as the neutral shape, and the expected slope for the black curve is twice times greater than that of the red curve, which is approximately the case for the estimation presented in the figure. The blue dashed curves correspond to temporal curves presenting constant acceleration (below the red curve) and deceleration (above the red curve). The shapes of these two curves are no longer linear, which is also expected. Finally, the dashed green curve corresponds to a frequency modulated curve, which thus presents successive accelerations and decelerations. The fluctuations are not very well reproduced in the estimation of this curve, but they are nevertheless quite visible in the temporal curve that is extracted by our algorithm.
This simple synthetic example, which nevertheless presents a relatively important temporal and shape variability coupled with an additive noise largely covering the neutral shape, shows that the initial objective behind this notion of separation of shape and time components within time series has some empirical grounds. The concept of time elastic centroid makes it possible, on this example, to approach this concept of neutral shape and furthermore allows for the extraction of the temporal functions associated to the shape utterances that are randomly produced by a stochastic generative process .
We are interested here in some experiments related to the identification of forgeries of some online genuine signatures. These signatures are collected using capture devices such as digitizing tables, digital pens or touch screens. The data is in the form of trajectories in , with (including at least positions and , and possibly pressure sensor output, stylus or pen orientations, etc.)
The tasks we consider are semi-supervised classification tasks that can be considered as being similar to anomaly detection tasks: only a few legitimate signatures are available for learning, forgery signatures can be considered as anomalies with respect to legitimate signatures.
The approach developed here consists in applying the separation algorithm on the training set, that is to say, to extract from legitimate signatures the neutral shape component and the temporal functions. From these shape and time components, we then construct an overall dissimilarity score between a test signature and our model that integrates a measure of shape dissimilarity and a measure of temporal dissimilarity.
The shape dissimilarity between a test time series and the neutral shape is estimated by evaluating the mean squared error of the differences between the samples of the neutral shape and the mathematical expectations of the samples of time series that are aligned with , as formalized by equation Eq. 11.
(11) |
The temporal dissimilarity is composed of the product of two terms, as specified by equation Eq. 12. The first term evaluates the absolute difference between the normalized averaged slope of temporal function
and unity. The averaged slope is obtained by a linear regression estimated on the temporal function. It is normalized using the mean slope
estimated on the linear regressions of the temporal function extracted from the training time series (which corresponds to legitimate signatures).The second term evaluates the absolute difference to unity of the area under the curve (AUC) for temporal function normalized by the mean AUC, noted , of the functions extracted on the training data.
(12) |
The global dissimilarity score correspond to the fusion of the two previous terms as specified in equation Eq.13. The meta parameter is used to adjust weight of importance between temporal and shape dissimilarities. This method for separating shape and temporal functions in time series along with the subsequent score aggregation model is call STS (shape and time separation) in the remaining part of the article.
(13) |
As an illustration, we present in Fig. 2, the result of our separating algorithm applied on a case extracted from the MOBISIG dataset presented below. On the top left sub-figure, the dark blue trajectory corresponds to the neutral shape, superimposed to the curves that correspond to the legitimate signatures used for training. On the top right sub-figure, temporal functions extracted from legitimate signatures are shown in cyan color, while temporal functions extracted from forgery signatures are shown in red color. On this example, most of the forgeries are characterized with a highly nonlinear temporal function, whose slope greatly increases near the middle of the signature realization. Moreover, comparatively to genuine signatures, forgeries are produced with slower temporal patterns. Clearly, on this example, the average slopes and AUCs are significantly higher for forgeries than for genuine signatures.
In Fig. 2
, bottom sub-figure, we show the 2D distributions corresponding to the dissimilarity scores, with the temporal dissimilarity in the x-axis and the shape dissimilarity in the y-axis. One can notice that, for the legitimate signatures (blue, cyan cluster), this 2D distribution is much more compact than it is for the 2D distribution associated to forgeries (red cluster). Furthermore, on this example, using the two dissimilarity scores jointly enable us to find a better separating hyperplane between the two clusters comparatively to the case where only one of the two scores is considered.
3D trajectories and neutral shape | Temporal functions, |
---|---|
2D score distributions | |
For the considered benchmarks, the assessment measures that are used are the following ones:
EER : (equal error rate) gives the error rate obtained when the false-positive rate is equal to the false-negative rate. In this configuration, rates are evaluated globally, i.e. when all subjects are treated together, without distinction.
aEER : (equal error rate) gives the average error rate obtained when the false-positive rate is equal to the false-negative rate. In this configuration, rates are evaluated subject by subject and then averaged.
FAR et FRR : true False Acceptance Rate and False Rejection Rate obtained when operating at the closest to the EER point.
The SVC2004 [Yeung2004svc2004] dataset is the first benchmark specifically designed for evaluating on-line handwritten signature verification systems. SVC2004 contains two distinct tasks: the first task only exploits the 2D (x,y) trajectories that are captured using a digitizing tablet (WACOM Intuos tablet) with a sampling frequency as well as the pen-down/pen-up binary information, that tells whether the contact between the pen and the tablet is established or not. The second task exploits supplementary information including the orientation of the pen. We have used the first task to determine a satisfactory value for meta parameter (cf. Eq. 13). Using a cross-validation we have obtained best EER values in average for . This value has been used (and maintain constant) to evaluate the STS approach on the second MOBISIG task as well as for the processing of all the other benchmarks described below.
The ICDAR2011 dataset [Liwicki2011] is made of 3D trajectories , produced by 10 subjects and captured using digitizing tablet Intuos3 (with a sampling frequency of ) and a pen. Here contains the pressure exerted on the pen.
The MOBISIG dataset [Antal2018] is made of pseudo-signatures produced by 83 subjects using one of their fingers and captured using a mobile tablet equipped with a touch screen. The signatures are captured with a sampling frequency of . The collected trajectories contain 2D positions and , the speeds and , accelerations and the pressure exerted on the touch screen , and the size of the contact area between the finger and the screen . We have applied the STS approach on the trajectories containing the previous features, without using the accelerations or the speeds dimensions that are more or less already encoded into the temporal functions we are extracting.
Benchmarks | Methods | aEER | EER | FAR | FRR |
SVC2004 | EdlA, [Sharma2016] | 2.71 | - | - | - |
SFT | 2.41 | 7.44 | 7.43 | 7.45 | |
ICDAR2011 | EdlA Dutch [Liwicki2011] | - | - | 3.44 | 3.86 |
SFT Dutch | 0.77 | 3.18 | 3.09 | 3.27 | |
EdlA Chinese [Liwicki2011] | - | - | 6.94 | 6.40 | |
SFT Chinese | 1.12 | 3.44 | 3.69 | 3.20 | |
MOBISIG (2017) | EdlA meilleur EER [Antal2018] | 9.35 | 14.31 | - | - |
EdlA meilleur aEER [Antal2018] | 5.81 | 29.76 | - | - | |
SFT | 4.19 | 5.86 | 5.86 | 5.86 |
The pre-processing that has been implemented is common to all the datasets. Basically we remove the mean and normalized the data using standard deviations for , and (the pen pressure). The other dimensions, if any, are normalized into the unit interval using .
Table Tab. I presents in a synthetic way results that have been obtained on the three benchmarks
that cover four distinct tasks. Our algorithm (STS) achieves slightly better results than the best methods that have been evaluated so far on these tasks. These results are quite encouraging since the nature of the capture devices as well as the cultural differences of the subjects (European and Asian) are relatively diversified. The state of the art is mostly composed with methods that are derived from DTW for SVC2004 and MOBISIG benchmarks, and with statistical methods or heuristics-based approaches that are not detailed for the ICDAR2011 benchmark. Neural-based approaches, particularly those involving deep learning or recurrent architectures, seem poorly suited to these tasks because of the limited size of the training sets.
The C++ code with a Python wraper is available at
https://github.com/pfmarteau/ShapeTimeSeparation/.
We have stated in this paper the problem of the separation of shape and time components in time series. If, in its general formulation, this problem is under-constrained (ill-posed), we have shown empirically, on synthetic data consisting of noisy ellipses, that a heuristic approach constructed around the notion of time elastic centroid can provide empirical solutions to this problem. In particular, the proposed algorithm makes it possible to identify a temporaly neutral shape and a set of associated temporal functions that are coherent with respect to the time series that are processed and close to our initial expectations.
Furthermore, we have also evaluated the interest of this separation in the scope of a signature authentication task consisting in detecting forgeries from the knowledge of a small set of genuine signatures. On three benchmarks implementing capture devices of variable nature and precision, the proposed approach, based on an aggregation of temporal and shape dissimilarity scores, slightly improves the results obtained by the best methods of the state of the art for each one of these benchmarks. These results are encouraging as the dissimilarity scores aggregating model that has been implemented is somehow quite simple.
The perspectives of this work concern the study and the modeling of the shape and temporal function variabilities in time series for the purposes of recognition or synthesis of shapes. The application aims are potentially very diverse, we can mention for instance the generation of expressive movements or realistic data that could be used to densify training sets.
Moreover, the presented algorithm is based on a global alignment principle, which is not adapted to the processing of certain class of time series such as chaotic series (because of the exponential dependence on the initial conditions). For such series, a solution based on temporally and spatially localized alignments could be possibly undertaken.
The authors would like to thank…
Comments
There are no comments yet.