Method and device for generating synthetic time series
The DTW-based method generates synthetic time series to address imbalanced labels in manufacturing models, enhancing model performance and interpretability by efficiently expanding the training dataset.
Patent Information
- Application Number
- DE102024201096
- Authority / Receiving Office
- DE · DE
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-02-07
- Publication Date
- 2025-08-07
AI Technical Summary
Existing classification and anomaly detection models for time series data in manufacturing processes suffer from imbalanced labels, with 'OK' instances outnumbering 'NOK' instances, leading to distorted model performance and reduced precision.
A method using dynamic time warping (DTW) to generate synthetic time series by iteratively determining probabilities from a time-series density matrix, adjusting these probabilities based on a hyperparameter, and randomly selecting positions to create synthetic time series, which are then used to expand the training dataset.
The method generates realistic synthetic time series efficiently, requiring less computational resources and hyperparameters, improving model performance by balancing the training dataset and enhancing interpretability.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
The invention relates to a method and an apparatus for generating synthetic time series for expanding a training dataset of training time series used for training a machine learning model. The invention further relates to a method for training machine learning models. The invention also relates to an inference method. The invention further relates to a control device. The invention also relates to a computer program and a computer-readable data carrier.Prior ArtThe center of modern manufacturing processes is the generation and analysis of data, which are decisive for the maintenance of the product quality and the efficiency of the production lines. Time series data are thereby of particular importance, which are acquired during the production processes and provide comprehensive insights into the production dynamics.However, a critical aspect of this data is its tendency to imbalanced labels, with the category "OK" for fault-free processes or parts occurring much more frequently than "NOK" for fault-free processes or parts. This disproportionation results in classical classification and anomaly detection models trained on these time series developing distortion in favor of the over-represented class, which affects the precision and reliability of the models.To cope with these challenges, synthetic generation of time-series data is increasingly focused. This method aims to make a balance in the training datasets by learning and modeling the characteristic features of real time series data, thereby enhancing model performance.Particular emphasis is given here to the technologies based on neural networks, which currently represent the prior art in the generation of synthetic time series. Specialized generative adventitial networks (GANs) such as TimeGAN and DoubleGanger, as well as probabilistic approaches such as the probabilistic autoregressive model (PAR), are centered in these methods to effectively address the challenges of imbalanced time-series data in the manufacturing industry.Even if approaches for generating synthetic time series are already known, development potential continues to exist.The object of the invention is thus to specify an improved method and / or an improved apparatus for generating synthetic time series.The object is achieved by a method for generating synthetic time series for expanding a training dataset of training time series according to the features of claim 1. The object is achieved by a method for training a machine learning model according to the features of claim 10.Disclosure of the InventionAccording to a first aspect, a method for generating synthetic time series for expanding a training dataset of training time series used for training a machine learning model is provided, the method for generating comprising:providing a time-series density matrix extracted from the training time-series based on time-series shift paths generated by a dynamic time-wrapping algorithm;providing a leading time series shift path based on the time series shift paths;providing a reference time series based on the training time series; generating a synthetic time series shift path by iteratively performing the following steps:starting from a respective starting position in the time-series density matrix, which preferably corresponds to a respective starting position of the synthetic time-series shift path, probabilities are determined on the basis of the time-series density matrix from the closest possible positions of the synthetic time-series shift path;identifying the position of the next possible positions at which a distance to the routing time series shift path is minimized;changing the determined probabilities of the closest possible positions of the synthetic time series shift path to be generated based on a predetermined hyperparameter of the lead time series shift path;setting a next position of the synthetic time-series shift path by randomly selecting one position from the changed next possible positions;generating a synthetic time series from the synthetically generated time series shift path and the reference time series to expand the training dataset of training time series.It goes without saying that the steps according to the invention and further optional steps do not necessarily have to be carried out in the sequence shown, but can also be carried out in a different sequence. Further intermediate steps can also be provided. The individual steps can also comprise one or more substeps without thereby departing from the scope of the method according to the invention.According to a second aspect, an apparatus for generating synthetic time series for expanding a training dataset of training time series used for training a machine learning model is provided. The apparatus has an evaluation and / or computing device which is designed to carry out the following steps:providing a time-series density matrix extracted from the training time-series based on time-series shift paths generated by a dynamic time-wrapping algorithm (DTW);providing a leading time series shift path based on the time series shift paths;providing a reference time series based on the training time series; generating a synthetic time series shift path by iteratively performing the following steps:starting from a respective starting position in the time-series density matrix, which preferably corresponds to a respective starting position of the synthetic time-series shift path, probabilities are determined on the basis of the time-series density matrix from the closest possible positions of the synthetic time-series shift path;identifying the position of the next possible positions at which a distance to the routing time series shift path is minimized;changing the determined probabilities of the closest possible positions of the synthetic time series shift path to be generated based on a predetermined hyperparameter of the lead time series shift path;setting a next position of the synthetic time-series shift path by randomly selecting one position from the changed next possible positions;generating a synthetic time series from the synthetically generated time series shift path and the reference time series to expand the training dataset of training time series.The explanations made for the method apply correspondingly to the device. It is understood that linguistic modifications of features formulated according to the method can be transformed for the device according to standard language practice without such formulations having to be explicitly listed here.The invention relates to a method for generating synthetic time series which can subsequently be used, for example, to train an anomaly detector. It is proposed that the DTW algorithm be used to obtain a matrix representation of time series. The synthetic time series are then preferably sampled from the matrix representation.Dynamic time warping (DTW) is an algorithm used to measure similarities between time sequences / time series that could differ in speed or length. In this case, the elements of two time series are matched to one another in such a way that the sum of the distances between paired elements is minimized. This distinguishes DTW from other distance measures such as the Euclidean distance, which requires a strict one-to-one correspondence between the points in the sequences and thus tolerates no time shift or stretch between the sequences. First, DTW creates a matrix in which the rows and columns correspond to the elements of the two time series. Each element of the matrix represents the distance between the points of the two sequences. The distances between each pair of points in the two time series are calculated (often using the Euclidean distance) and entered into the matrix. DTW passes through the matrix to find the path / path with the smallest cumulative distance. This path represents the best correspondence between the points in the two time series. The path / path is chosen so that each point in each sequence is assigned at least once, and the assignment minimizes the total distance. Optionally, the cumulative distance is divided by the number of steps in the path to normalize sequence length effects. An advantage of DTW is its flexibility in handling time series that differ in length or are shifted in time.The method for generating synthetic time series can also be understood as a method for training the DTW algorithm. Namely, synthetic time series can then be generated on the basis of the trained DTW algorithm. Preferably, a plurality of time series is generated with the present method. The time-series shift path may also be understood as a time-series distortion path or a time-series curvature path.The method preferably starts as an initial starting position for generating a respective synthetic time-series shift path at the index position (0,0) of the time-series density matrix. On the basis thereof, a new time series shift path is then iteratively scanned (per index position, in particular until a specific size and / or an abort criterion is reached.To generate synthetic time series, within the scope of the invention, new 2D representations of time series shift paths are derived from the time series density matrix. Using a reference time series, the sampled 2D representations of the time series displacement paths may then be transformed back into the original (one or multi-dimensional) time series space. The proposed DTW-based synthetic time series generation approach is more efficient and interpretable than existing synthetic time series generation approaches.The invention alleviates the disadvantages of the prior art in neural networks for generating time series, including their high resource consumption, sensitivity to hyperparameters and lack of interpretability. The presented method for generating synthetic time series uses an efficient open-source implementation of the dynamic time warping algorithm. The generation itself is done based only on a set of 2D representations of time-series shift paths. This hardly requires any storage and computing power. Further, the method may generate realistic synthetic time series with a fraction of the training data required by neural networks. Accordingly, the method is more efficient than the approaches to generating synthetic time-series data using existing deep neural networks. The method for generating preferably requires only a small number of hyperparameters, in particular hyperparameters specified by a user. The method also uses a simple (deterministic) algorithm to generate synthetic time series from a sampled 2D representation of time series shift paths. The proposed approach is therefore interpretable.The method for generating synthetic time series data is an upstream part in the machine learning tool string. It does not directly improve a machine learning system that can be used for the applications mentioned below, but is a generative model for generating and expanding training and / or test data. After the machine learning model has been trained in this way, it can subsequently be used in an optimized manner.In one embodiment, providing the time-series density matrix comprises:calculating a respective time series shift path between the reference time series and the respective training time series based on the dynamic time wrapping algorithm; andaggregating the calculated time-series shift paths into the time-series density matrix.The time series shift path is preferably calculated for each time series of the training time series or at least for a part of the time series of the training time series. The present method uses dynamic time warping (DTW) to calculate the respective time-shifting path between each training time series and a reference time series. The respective time-shift path preferably defines the set of index pairs that describes the best possible match between the respective training time series and the reference time series in terms of similarity. In particular, the closest corresponding indices in the reference time series are identified by the dynamic time warping (DTW) for each index in a (training) time series. A time-series shift path may be represented / mapped by a 2D matrix that contains "1" in each field corresponding to an index match, and "0" otherwise.By aggregating the 2D time-shift matrices of the time-shift paths of the analyzed training time series, the time-series density matrix representing the density of the time shifts in the training data can be determined. The time-series density matrix describes the time warping characteristics of the training set. New, synthetic time shift paths can then be iteratively derived from this time series density matrix. The synthetic time-shift paths will then be used to generate synthetic time series.In one embodiment, before aggregating, the time-series shift paths are weighted.The weights may be set or otherwise determined by a user, for example.In one embodiment, the reference time series can be selected by a user from the training time series or another time series data set, or can be extracted from the training time series, in particular by averaging over at least a part of the training time series, or can be determined by calculating a barycentre of at least a part of the training time series which is to serve as a reference.The barycentre is preferably a hypothetical and / or synthetic time series which minimizes the DTW distance to all training time series. The reference time series can also be provided in another manner, for example on the basis of historical data.In one embodiment, the routing time-series shift path is randomly selected from the time-series shift paths.The random criterion used to decide this is fundamentally arbitrary. A random time shift path is therefore extracted from the training data set, which is intended to serve as a "guide line" for generating the synthetic time series shift paths.In one embodiment, the iterative execution takes place until an abort criterion is reached, in particular a predetermined path size and / or path length of the time series shift path to be generated synthetically.In principle, a number of iterations can also serve as termination criterion. Alternatively or additionally, a length of the reference time series can also serve as termination criterion.In an embodiment, determining probabilities based on the time-series density matrix of closest possible positions of the synthetic time-series shift path comprises: based on the starting position in the time-series density matrix, determining the Markov probabilities of the closest possible positions, in particular by dividing the corresponding count values in the time-series density matrix by their respective sums.Preferably, therefore, the Markov probability of the possible next positions is determined on the basis of the respectively current position (varying per iteration step) in the time-series density matrix, the probability of the possible next position being determined here for a step to the right, for a step to the top and / or for a step along the diagonal starting from the respective starting position. This is done in particular by dividing the corresponding count values in the time-series density matrix by their sum.In one embodiment, the hyperparameter has a sample temperature of the lead time series shift path, which is especially determinable by a user.The sample temperature describes a hyperparameter that describes the randomness of the sample path of the lead time series shift path. The sample temperature is preferably set to be less than 1. It is also preferable to identify a possible next step closest to the sampled routing time series shift path. The probabilities are preferably changed in accordance with the set sample temperature. If the sample temperature is 0, then the newly generated time series shift path preferably exactly follows the lead time series shift path. Preferably, the sample temperature is set to about 0.5.In an embodiment, generating the synthetic time series from the synthetically generated time series shift path and the reference time series comprises:matching discrete time-series values of the reference time series with a respective index position of the synthetically produced time-series shift path to produce a respective discrete synthetically produced time-series value; and optionally interpolating missing values and / or smoothing the synthetic time series produced on the basis of the discrete synthetically time-series value.For each position in the synthetically produced time series shift path, the corresponding value from the reference time series is preferably appended to the new time series. When a position of the synthetically generated time series shift path is associated with a plurality of values from the reference time series, the average value thereof is preferably appended to the time series to be generated. In this way, no information is lost from the reference time series. When a plurality of positions of the synthetically generated time series shift path are associated with the same value of the reference time series, preferably the value is appended only once to the time series to be generated and a non-allocation value (NaN) is set at the remaining positions. Namely, if the same value of the reference time series were repeatedly appended to the time series to be generated, the synthetic time series to be generated would look like a step function (i.e., it would have multiple plateaus) because dynamic time warping results in discrete position matches. This is to be avoided. Interpolation is particularly preferably carried out for the NaN values. Preferably, a smoothing window of a predetermined size may also be used. In this way, an interpolated and / or smoothed synthetic time series can be provided.In the present case, a method for training machine learning model for classification or abnormality detection, in particular in production processes, is also specified. The method comprising the steps of:providing an expanded training dataset of training time series expanded by synthetically generated time series according to the present method for generating synthetic time series;training the machine learning model based on the expanded training dataset; andproviding the trained machine learning model for classification or anomaly detection, in particular during production processes.The proposed algorithm can be trained in a monitored and unsupervised manner. In the supervised training scenario, the steps are preferably performed independently of each other for each class.In the present case, an inference method for classification or abnormality detection, in particular in production processes, is also claimed. The inference method includes the steps of:providing time series data which are detected by a sensor; and classifying the provided time series data and / or detecting anomalies in the provided time series data by a machine learning model trained in the present case.The present inference method may be further used for analysis of sensor data. A sensor can capture measurements of the environment in the form of sensor signals. These sensor signals can have one- or multi-dimensional time series, for example from a repeatable process (e.g. a pressing or screwing process).The present inference method and / or method of generating may also be used to detect anomalies in a technical system. For example, synthetic time series may be generated to extend an existing set of time series to increase and / or make the set more balanced (e.g., "OK" / "NOK" time series). Training the machine learning model to detect anomalies based on the expanded dataset results in improved model performance compared to training that occurs based only on the originally acquired time series.In the present case, a control device is also claimed which is included for a partially automated or automated driving function of a motor vehicle and / or of a drone and / or in a robotic system and / or in an industrial machine and / or is used for the optical inspection, and on which a machine learning model trained according to the invention can be executed.The present method of generating synthetic time series may be useful wherever a machine time series learning model suffers from imbalanced training data. The present method for generating synthetic time series is particularly preferred for the detection of anomalies in production processes that include, for example, time series sensor data, such as, purely by way of example, temperature data, pressure data, force data, and / or torque data, with a discrepancy between "OK" and "NOK" fractions (anomalies). Namely, known machine learning models for abnormality detection tend to overlook the differences between "OK" and "NOK" in time series, particularly when the models are trained on "OK" instances. The present method of generating synthetic time series can accommodate this behavior, as synthetic time series can be generated to obtain a more balanced training set of training time series (e.g., also covering NOK) to improve generalization capabilities in anomaly detection. The same advantage also applies to the classification of time series, for example if a distinction is to be made between more or less frequent fault types. The present method for generating synthetic time series can prevent overfitting when training machine learning models.The present method for generating synthetic time series is also useful for expanding training data sets from the real world, for example if data acquisition is (structurally) technically complicated and / or expensive. For example, it may also be that for data protection reasons it is not possible to provide extensive time-series data, e.g. from a mobile smart device or a smart home device. The present method for generating synthetic time series allows a small dataset to be expanded and used for training a model. Likewise, transmitting vehicle sensor measurements across the cloud may be expensive to collect training data in large quantities. The present method for generating synthetic time series allows a small dataset to be expanded and used for training a model. The present method for generating synthetic time series is capable of generating synthetic time series based on only a few time series. It is preferred that the output time series available for the generation enable a realistic 2D time shift representation. This is an advantage of the invention, as known approaches, for example based on neural networks, in contrast require large amounts of training data to generate realistic synthetic time series.In the present case, a computer program with program code is also claimed in order to execute at least parts of the method according to the invention in one of its embodiments when the computer program is executed on a computer. In other words, according to the invention, a computer program (product) comprising instructions which, when the program is executed by a computer, cause the computer to execute the method / steps of the method according to the invention in one of its embodiments.In the present case, a computer-readable data carrier with program code of a computer program is also proposed in order to execute at least parts of the method according to the invention in one of its embodiments when the computer program is executed on a computer. In other words, the invention relates to a computer-readable (storage) medium comprising instructions which, when executed by a computer, cause the computer to carry out the method / steps of the method according to the invention in one of its embodiments.The described embodiments and developments can be combined with one another as desired.Further possible embodiments, developments and implementations of the invention also include combinations of features of the invention described above or below with respect to the exemplary embodiments, which combinations are not explicitly mentioned.Brief Description of the DrawingsThe accompanying drawings are intended to provide a further understanding of the embodiments of the invention. They illustrate embodiments and, in conjunction with the description, serve to explain principles and concepts of the invention.Other embodiments and many of the advantages mentioned are evident with reference to the drawings. The elements of the drawings shown are not necessarily shown true to scale with respect to one another.The following are shown: FIG. 1 is a schematic flow diagram of an embodiment of the method for generating synthetic time series; FIG. 2 shows a schematic illustration of a determination of a time-wrapping path; FIG. 3 shows a schematic illustration of a determination of a time-series density matrix; FIG. 4 shows a schematic flow diagram for generating a synthetic time wrap path; and FIG. 5 shows a schematic illustration for generating a synthetic time series from a synthetic time wrap path.In the figures of the drawings, identical reference numerals designate identical or functionally identical elements, components or components, unless indicated to the contrary.FIG. 1 shows a schematic flow diagram of a method for generating synthetic time series for expanding a training dataset of training time series used for training a machine learning model.In any embodiment, the method can be carried out at least partially by a device 100, which can comprise a plurality of components, not shown in detail, for example one or a plurality of provision devices and / or at least one evaluation and computing device. It is understood that the provision device can be formed jointly with the evaluation and computing device or can be different therefrom. Furthermore, the apparatus can comprise a storage device and / or an output device and / or a display device and / or an input device.According to the invention, the computer-implemented method comprises at least the following steps:In a step S 1, a time-series density matrix is provided, which is extracted from the training time series on the basis of time-series shift paths generated by a dynamic time-wrapping algorithm.In a step S 2, a guide time series shift path is provided on the basis of the time series shift paths.In a step S 3, a reference time series is provided on the basis of the training time series;In a step S 4, a synthetic time series shift path is generated by iteratively performing the following steps:In a step S 41, starting from a respective starting position in the time-series density matrix, which preferably corresponds to a respective starting position of the synthetic time-series shift path, probabilities are determined on the basis of the time-series density matrix from the closest possible positions of the synthetic time-series shift path.In a step S 42 the position of the next possible positions at which a distance to the routing time series shift path is minimized is identified.In a step S 43, the ascertained probabilities of the next possible positions of the synthetic time series shift path to be generated are changed on the basis of a predetermined hyperparameter of the guide time series shift path.In a step S44, a next position of the synthetic time-series shift path is set by randomly selecting one position from the changed next possible positions.In a step S 5, a synthetic time series is generated from the synthetically generated time series shift path and the reference time series in order to expand the training data set of training time series.FIG. 2 shows a schematic illustration of a transition of a training time series 200 into a 2D matrix illustration 202 of a time series shift path 204 by a dynamic time wrapping algorithm. In this case, the time series shift path 204 is calculated on the basis of the dynamic time wrapping algorithm between a reference time series 206 and the training time series 200. A time-series shift path may be represented / mapped by the 2D matrix 202 that contains "1" in each field corresponding to an index match between the reference time series 206 and the training time series 200, and "0" (not shown or left empty), otherwise.FIG. 3 shows a schematic illustration for generating a time-series density matrix 300. After the respective 2D matrix representation 202 of the respective time series shift path 204 is available for each or at least a subset of the training time series 200, the 2D matrix representation 202 of the calculated time series shift paths 204 are aggregated or summed up to form the time series density matrix 300.FIG. 4 shows how a synthetic time-series shift path 204' is generated based on the density matrix. Starting from a respective starting position 400, initially the position (0, 0) in the time-series density matrix 300, which preferably also corresponds to a starting position of the later synthetic time-series shift path 204', probabilities 401 are determined on the basis of the time-series density matrix 300 from the next possible positions of the synthetic time-series shift path 204'. Furthermore, that position of the next possible positions is then identified, at which a distance to a guide time series shift path 402 is minimized. Furthermore, the determined probabilities 401 are changed to 401' of the next possible positions of the synthetic time series shift path 204' to be generated on the basis of a predetermined hyperparameter H of the lead time series shift path. A next position 404 of the synthetic time-series shift path 204' is set by randomly selecting one position from the changed, next possible positions. The iterative execution then takes place until an abort criterion is reached, in particular a predetermined path size and / or path length of the time series shift path 204' to be generated synthetically.FIG. 5 shows how a synthetic time series 500 can be generated from the synthetically generated time series shift path 204' and the reference time series 206. In this case, discrete time series values 502 of the reference time series 206 are matched to a respective index position 504 of the synthetically produced time series shift path 204' in order to produce a respective discrete, synthetically produced time series value 506. Optionally, it is also possible to interpolate missing values and / or smooth the synthetic time series 500 generated on the basis of the discrete, synthetic time series value 506. In this way, an interpolated and / or smoothed synthetic time series 500' can then preferably be provided. For each position in the synthetically generated time series shift path 204', the corresponding value 502 from the reference time series 206 is preferably appended to the new time series 500. If a position of the synthetically generated time series shift path 204' is connected to a plurality of values 502 from the reference time series 206, its average value M is preferably appended to the time series 500 to be generated. In this way, no information is lost from the reference time series 206. Preferably, if multiple positions of the synthetically generated time series shift path 204' are associated with the same value 502 of the reference time series 206, the value is appended only once to the time series 500 to be generated and a no-allocation value NaN is set at the remaining positions. Interpolation is particularly preferably carried out for the NaN values. Preferably, a smoothing window of a predetermined size may also be used.
Claims
A method for generating synthetic time series (500) for expanding a training dataset of training time series (200) used for training a machine learning model, the method for generating comprising: providing (S1) a time series density matrix (300) extracted from the training time series (200) on the basis of time series shift paths (204) generated by a dynamic time wrapping algorithm; providing (S2) a lead time series shift path (402) on the basis of the time series shift paths (204); providing (S3) a reference time series (206) on the basis of the training time series (200); generating (S4) a synthetic time-series shift path (204') by iteratively performing the following steps: starting from a respective starting position (400) in the time-series density matrix (300), which preferably corresponds to a respective starting position of the synthetic time-series shift path (204'), ascertaining (S41) probabilities (401) on the basis of the time-series density matrix (300) from the closest possible positions of the synthetic time-series shift path (204'); identifying (S42) that position of the closest possible positions at which a distance to the lead time-series shift path (402) is minimized; changing (S43) the determined probabilities (401, 401') of the closest possible positions of the synthetic time series shift path (204') to be generated on the basis of a predetermined hyperparameter (H) of the leading time series shift path (402); setting (S44) a next position (404) of the synthetic time series shift path (204') by randomly selecting a position from the changed closest possible positions; generating (S5) a synthetic time series (500, 500') from the synthetically generated time series shift path (204') and the reference time series (206) for expanding the training dataset of training time series (200).The method of claim 1, wherein providing (S1) the time-series density matrix (300) comprises: calculating a respective time-series shift path (204) between the reference time-series (206) and the respective training time-series (200) based on the dynamic time-wrapping algorithm; and aggregating the calculated time-series shift paths (204) to the time-series density matrix (300).The method of claim 2, wherein prior to aggregating, weighting of the time-series shift paths (204) occurs.Method according to one of the preceding claims, wherein the reference time series (206) can be selected by a user from the training time series (200) or another time series data record, or can be extracted from the training time series (200), in particular by averaging over at least a part of the training time series (200), or can be determined by calculating a barycentre of at least a part of the training time series (200).The method of any preceding claim, wherein the routing time-series shift path (402) is randomly selected from the time-series shift paths (204).Method according to one of the preceding claims, wherein the iterative execution (S4) takes place until an abort criterion, in particular a predetermined path size and / or path length, of the time series shift path (204') to be generated synthetically is reached.The method according to any of the preceding claims, wherein the determining (S41) probabilities (401) based on the time-series density matrix (300) of closest possible positions of the synthetic time-series shift path (204') comprises: based on the starting position (400) in the time-series density matrix (300), determining the Markov probabilities of the closest possible positions, in particular by dividing the corresponding count values in the time-series density matrix by their respective sums.Method according to one of the preceding claims, wherein the hyperparameter (H) has a sample temperature of the guide time series displacement path (402), which can be specified in particular by a user.The method of any preceding claim, wherein generating (S5) the synthetic time series (500, 502') from the synthetically generated time series shift path (204') and the reference time series (206) comprises: matching discrete time series values (502) of the reference time series (206) with a respective index position (504) of the synthetically generated time series shift path (204') to generate a respective discrete synthetically generated time series value (506); and optionally interpolating missing values and / or smoothing the synthetic time series (500') generated based on the discrete synthetically time series value.Method for training machine learning model for classification or anomaly detection, in particular in production processes, the method having the steps: - providing an extended training dataset of training time series which is extended by synthetically generated time series (500, 500') according to the method according to one of the preceding claims; - training the machine learning model on the basis of the extended training dataset; and - providing the trained machine learning model for classification or anomaly detection, in particular in production processes.An inference method for classification or anomaly detection, in particular in production processes, comprising the steps of: providing time series data acquired by a sensor; and classifying the provided time series data or detecting anomalies in the provided time series data by a machine learning model trained according to the method of claim 10.Control device for an automated driving function of a motor vehicle, an automated function of a drone, a robot and / or for an automated optical inspection of components and / or samples, wherein the control device is designed to execute a method according to claim 11.Device (100) for generating synthetic time series for expanding a training dataset of training time series used for training a machine learning model, the device (100) having an evaluation and / or computing device which is designed to carry out the following steps: providing (S1) a time series density matrix (300) which is extracted from the training time series (200) on the basis of time series shift paths (204) generated by a dynamic time wrapping algorithm; providing (S2) a guide time series shift path (402) on the basis of the time series shift paths (204); providing (S3) a reference time series (206) on the basis of the training time series (200); generating (S4) a synthetic time-series shift path (204') by iteratively performing the following steps: starting from a respective starting position (400) in the time-series density matrix (300), which preferably corresponds to a respective starting position of the synthetic time-series shift path (204'), ascertaining (S41) probabilities (401) on the basis of the time-series density matrix (300) from the closest possible positions of the synthetic time-series shift path (204'); identifying (S42) that position of the closest possible positions at which a distance to the lead time-series shift path (402) is minimized; changing (S43) the determined probabilities (401, 401') of the closest possible positions of the synthetic time series shift path (204') to be generated on the basis of a predetermined hyperparameter (H) of the leading time series shift path (402); setting (S44) a next position (404) of the synthetic time series shift path (204') by randomly selecting a position from the changed closest possible positions; generating (S5) a synthetic time series (500, 500') from the synthetically generated time series shift path (204') and the reference time series (206) for expanding the training dataset of training time series (200).Computer program with program code for executing at least parts of a method according to one of Claims 1 to 11 when the computer program is executed on a computer.Computer-readable data medium with program code of a computer program for executing at least parts of a method according to one of Claims 1 to 11 when the computer program is executed on a computer.