Sales forecasting and abnormality early warning system based on time series analysis
By adopting a system architecture that integrates multi-source data access, time-series data preprocessing, multi-scale fusion time-series prediction, and dynamic threshold anomaly warning, the system solves the problems of poor scenario adaptability and high false alarm rate of existing sales forecasting and anomaly warning solutions. It achieves high-precision sales forecasting and anomaly identification, adapting to changes in complex business environments.
Patent Information
- Application Number
- CN202611307858.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-27
- Publication Date
- 2026-11-24
AI Technical Summary
Existing sales forecasting and anomaly warning solutions suffer from poor scenario adaptability, high false alarm and false negative rates, and model accuracy that is prone to rapid decline with changes in business.
The system architecture adopts multi-source data access, time series data preprocessing, multi-scale fusion time series prediction, dynamic threshold anomaly early warning and early warning closed-loop handling. Through the multi-scale decomposition-integration time series prediction architecture, dynamic threshold anomaly early warning and early warning closed-loop handling mechanism, it realizes multi-dimensional modeling and real-time adjustment of sales time series.
It significantly improves the accuracy of full-cycle sales forecasting and adaptability to complex scenarios, reduces the number of invalid warnings, improves the accuracy of anomaly identification, and quickly adapts to changes in business models, ensuring the stability and accuracy of the system's long-term operation.
Smart Images

Figure CN123160213A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of retail sales time-series forecasting and anomaly early warning technology, and in particular to a sales forecasting and anomaly early warning system based on time-series analysis. Background Technology
[0002] Currently, offline chain retail, omni-channel e-commerce and other consumer circulation sectors generally face pain points such as difficulty in predicting sales fluctuations, low inventory turnover efficiency, and delayed response to abnormal events. As the omni-channel sales chain is gradually opened up and consumption scenarios become more diversified, sales data exhibits multi-dimensional correlation, high non-linear fluctuations, and dense time-series characteristics. Enterprises have an increasing demand for accurate sales forecasting and timely abnormal warnings. The core objective is to balance inventory costs and stockout risks, respond quickly to sudden business problems, and optimize operational efficiency.
[0003] Currently, mainstream sales forecasting and anomaly warning solutions mainly fall into two categories: The first category is based on traditional statistical models, which use single statistical models such as autoregressive moving averages and exponential smoothing to fit the time-series patterns of historical sales and output future sales forecasts. The warning process uses a fixed percentage threshold as the anomaly detection standard. This type of solution is easy to implement, has low deployment costs, and strong model interpretability, making it widely used in small retail scenarios with simple business formats and stable sales fluctuations. However, it has poor adaptability to nonlinear external covariates such as marketing activities, holidays, and weather, and cannot accurately capture the sales fluctuation patterns in special scenarios. The prediction accuracy decays rapidly over time. At the same time, the fixed threshold cannot adapt to the sales fluctuation characteristics of different time periods. Normal sales increases during peak periods such as promotional periods and morning / evening rush hours are easily misjudged as anomalies, while minor fluctuations during off-peak periods are easily missed. Overall, the false positive and false negative rates remain high.
[0004] The second category is prediction schemes based on single-scale deep learning models. These schemes use deep learning models such as Long Short-Term Memory (LSTM) networks and Temporal Transformers to train the prediction network. They can incorporate multi-dimensional covariates into the modeling, resulting in better fitting capabilities than traditional statistical models. The early warning stage uses fixed confidence intervals as the anomaly detection criteria, making them widely used in e-commerce scenarios with complex sales fluctuations. However, these schemes use single-time granularity modeling, making it difficult to simultaneously balance the sensitivity of short-term predictions with the stability of long-term predictions. They may either overfit short-term noise, leading to directional deviations in long-term trends, or oversmooth short-term fluctuations, resulting in untimely identification of sudden anomalies. Furthermore, these models typically use a one-time training and deployment model, lacking a closed-loop iterative mechanism based on business feedback. When business models are adjusted or consumer habits change, the prediction accuracy will continuously decline, and the early warning accuracy will also decrease accordingly, making them unsuitable for dynamically changing business scenarios. Summary of the Invention
[0005] The present invention proposes a sales forecasting and anomaly early warning system based on time series analysis to solve the problems mentioned in the prior art, such as poor scenario adaptability, high false alarm and missed alarm rates, and rapid decay of model accuracy with changes in business.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: a sales forecasting and anomaly early warning system based on time series analysis, comprising a multi-source data access unit, a time series data preprocessing unit, a multi-scale fusion time series forecasting unit, a dynamic threshold anomaly early warning unit, and an early warning closed-loop processing unit; The multi-source data access unit is used to collect five types of time-series data in real time: structured POS transaction flow, WMS inventory turnover, OMS marketing activity configuration, public domain channel traffic acquisition, statutory holidays and regional characteristic festivals. It adopts an access mode that combines scheduled batch retrieval with real-time push of Kafka message queue. It completes millisecond-level timestamp alignment of all access data with a minimum statistical granularity of 1 minute. It writes the data into a distributed time-series database using TSDB compression storage engine according to a three-dimensional tag system of product category, sales region and store level. This solves the prediction lag problem caused by inconsistent time dimensions of multi-source data and excessive data latency from the access layer. The time series data preprocessing unit sequentially performs intelligent missing value completion, non-stationary noise smoothing, and time series stationarity ADF verification on the incoming raw time series data. It also labels each time series sample point with covariate labels and data confidence labels, generating a standardized time series sample set that can be used for modeling. This eliminates the interference of raw data quality defects on the accuracy of subsequent modeling from the data layer. The multi-scale fusion time series forecasting unit adopts a decomposition-integration parallel modeling architecture, which independently models the sales time series at three time granularities: daily, weekly, and monthly. After adaptive weighted fusion, it outputs the sales forecast value and point-by-point prediction confidence interval covering the entire cycle from the next 1 day to 90 days, realizing the collaborative capture of sales patterns across different time spans. The dynamic threshold anomaly warning unit combines point-by-point prediction confidence intervals to construct anomaly discrimination thresholds that are dynamically adjusted over time and in different scenarios. It identifies abnormal sales fluctuations that exceed the threshold range in real time, matches three warning levels based on the magnitude of the fluctuation deviation, and generates standardized warning work orders that include the location of the anomaly, the degree of deviation, and possible causes. This solves the problems of high false alarm rate and poor scenario adaptability of traditional fixed threshold warnings. The early warning closed-loop handling unit pushes early warning information in a targeted manner according to the response link corresponding to the early warning level, records the abnormal handling actions and result feedback of each response end throughout the process, and continuously iterates and optimizes the system model parameters based on the incremental samples formed by the handling feedback, so as to achieve a closed-loop improvement in prediction accuracy and early warning accuracy.
[0007] Furthermore, when the time-series data preprocessing unit performs missing value completion, for short-term missing time series with a continuous missing duration of less than 3 statistical granularities, a time-distance weighted sliding window interpolation method is used to complete the completion. The interpolation weight of the point is inversely proportional to the time distance from the point to be completed to the adjacent valid point. For long-term missing time series with a continuous missing duration of more than 3 statistical granularities, the time-series correlation mapping value of the same category, the same business district level, and the same scale of stores is introduced to complete the completion. During the completion process, a confidence weight in the range of 0 to 1 is marked for each completed point according to the historical accuracy of the completion method. In the subsequent modeling stage, the completed data is called in a weighted manner according to the confidence weight, which reduces the interference of missing value completion deviation on model training from the source and solves the problem of insufficient accuracy of traditional unified interpolation methods for long-term missing value completion.
[0008] Furthermore, when the time series data preprocessing unit performs noise smoothing after completing missing value completion, it uses a sliding window discrete wavelet transform to remove impulse outlier noise from the sales time series. The wavelet basis is selected as the db4 orthogonal wavelet, which matches the cyclical fluctuation characteristics of retail sales. The number of wavelet decomposition levels is adaptively adjusted according to the current processing time series statistical granularity. Daily granular data is set to 4 levels of decomposition, weekly granular data is set to 3 levels of decomposition, and monthly granular data is set to 2 levels of decomposition. In the threshold quantization stage, a soft threshold function is used to filter out high-frequency noise components caused by order entry operation deviations and system counting jump errors. After reconstruction, the long-term trend components, seasonal cycle components, and random fluctuation residual components corresponding to the real sales are retained to avoid noise points being misjudged as abnormal sales fluctuations and to improve the data input quality of subsequent prediction and early warning stages.
[0009] Furthermore, the decomposition-integration architecture of the multi-scale fusion time series forecasting unit first decomposes the preprocessed standardized sales time series into long-term trend components, seasonal cycle components, and random residual components using a robust STL time series decomposition method. The trend component captures the long-term variation pattern of sales with business development and is modeled using a linear trend extrapolation model with L2 regularization. The cycle component captures the influence of fixed-cycle fluctuations and external covariates such as holidays and marketing activities and is modeled using a lightweight time series convolutional network with covariate embedding layers. The residual component captures random fluctuations that cannot be explained by the first two components and is modeled using a seasonal autoregressive moving average model. The outputs of the three components are dynamically adjusted by component weights to obtain the single-scale sales forecast value at the corresponding time point, realizing hierarchical modeling of different fluctuation patterns and avoiding the problem of insufficient fitting ability of a single model for complex sales time series.
[0010] Furthermore, the multi-scale fusion time-series prediction unit constructs parallel prediction sub-models at three time granularities: daily, weekly, and monthly. The preliminary prediction results of adjacent granularities are corrected for deviations by a bidirectional consistency verification module, following a "top-down trend constraint, bottom-up fluctuation supplementation" sequence. The low-granularity monthly model provides long-term trend constraints for the high-granularity daily and weekly models, scaling corrections proportionally when deviations exceed thresholds. The high-granularity daily model supplements short-term fluctuation details for the low-granularity weekly and monthly models, improving the sensitivity of long-term predictions to sudden sales fluctuations. The outputs of each scale sub-model are adaptively weighted and fused to obtain the final sales prediction value. The fusion calculation satisfies the following relationship: ,in for The final sales forecast at any given time. for Moment corresponds to time scale The model output weights, Pick Time corresponds to daily model, take Time corresponds to weekly model, take The corresponding monthly model For the corresponding scale The output of the sub-model The sales forecast value at time t is such that all weights satisfy the constraint that the sum of all weights is 1. The weight values are dynamically allocated based on the average absolute percentage error of the predictions of each scale model in the 12 sliding statistical periods before time t. The period unit is consistent with the time granularity of the corresponding sub-model. The weight is calculated based on the inverse of the error normalization. The model with higher accuracy has a larger weight, so as to achieve the synergistic effect of the prediction advantages of different granularities.
[0011] Furthermore, when constructing the discrimination threshold for the dynamic threshold anomaly early warning unit, the traditional discrimination logic of fixed thresholds throughout the entire time period is abandoned. Instead, the sales forecast value at each time point is used as the benchmark, and the upper and lower discrimination thresholds that dynamically fluctuate over time are calculated by combining the prediction confidence interval width, the variance of historical sales fluctuations in the same period, and the intensity of marketing activities in the current period. The threshold calculation satisfies the following relationship: ;in , These are the upper and lower thresholds for anomaly detection at time t, respectively. for Threshold sensitivity adjustment coefficient at time step for The standard deviation of the predicted values output by the time-based prediction model is used to characterize the width of the prediction confidence interval for the current location. for The standard deviation of sales fluctuations for the corresponding three historical sales cycles at any given time. for The standard deviation of expected sales fluctuation corresponding to a marketing campaign at any given time, measured in units sold, is used to characterize the magnitude of sales fluctuation brought about by the marketing campaign; when there is no marketing campaign... When the value is 0, it indicates that an S-level omnichannel promotion is being conducted. Take the mean of the standard deviation of sales fluctuations from similar historical promotional events. , , The initial weights of the three influencing factors are assigned, and the sum of the three is always 1; The threshold calculation process is adaptively adjusted based on the model prediction accuracy over nearly 30 statistical periods. The higher the prediction accuracy, the better. The smaller the value and the stricter the threshold, the lower the prediction accuracy. The larger the value and the more lenient the threshold, the better the balance between the false alarm rate and the false negative rate of anomaly detection.
[0012] Furthermore, when matching the alert level with the dynamic threshold anomaly alert unit, the relative deviation between the real-time collected actual sales value and the corresponding dynamic threshold is divided into three alert levels. The first level is a general alert, where the deviation is in the first range (the actual value exceeds the threshold but the relative deviation is less than 20%). The corresponding work order is pushed to the store operation end to prompt the store to conduct daily sales anomaly verification. The second level is a critical alert, where the relative deviation is between 20% and 50%. The corresponding work order is pushed to the regional operation management end to prompt the regional supply scheduling and marketing effect review. An emergency warning is issued if the deviation exceeds the second range, i.e., the relative deviation ratio is higher than 50%. The corresponding work order is simultaneously pushed to the supply chain management and marketing decision-making end, prompting the implementation of full-chain inventory adjustments and marketing plan optimizations. Different levels of warnings are set with differentiated response time requirements to achieve precise allocation of warning resources and avoid non-core anomalies occupying too many decision-making resources.
[0013] Furthermore, when the early warning closed-loop handling unit iteratively updates the model parameters, it stores the actual sales value of the early warning point, the root cause of the anomaly, the specific handling measures taken, and the sales change trend after handling as labeled and effective new samples in the time series sample library. It triggers the incremental training of the multi-scale fusion time series prediction unit according to the set weekly update cycle, and simultaneously corrects the weights of each influencing factor in the dynamic threshold calculation process. This enables the model to quickly adapt to recent changes in sales patterns, solves the problem of prediction accuracy decaying over time due to long-term non-update after one-time training of traditional models, and continuously improves the matching degree between prediction results and actual business scenarios.
[0014] Furthermore, it also includes configurable visual interactive units for multi-dimensional display of the historical trend of full sales volume over time, short, medium and long-term full-cycle prediction curves, and the spatial and temporal distribution of abnormal warning points. It supports users to customize and adjust the prediction time range and warning threshold sensitivity parameters according to management needs. It supports drilling down to view the corresponding dimension's sales details, historical warning records and handling results by category, sales region and store level. It also supports users to manually mark special sales event points and synchronize them to the time series sample library, supplementing the model training with manually labeled scene tags, and further improving the model's ability to identify special events.
[0015] Furthermore, when the early warning closed-loop handling unit triggers incremental model training, a dual triggering mechanism is set. If the cumulative number of newly added valid samples in the time series sample library reaches the set sample capacity threshold, or if the overall prediction accuracy of the model for three consecutive prediction periods is lower than the set accuracy threshold, the full parameter fine-tuning of the model is automatically triggered. During the fine-tuning process, a transfer learning approach is adopted, retaining the general sales trend extraction parameters and periodic pattern extraction parameters obtained from historical model training (corresponding to the first two shallow layers of the time series convolutional network), and only updating the top-level network parameters (the last convolutional layer and the fully connected output layer) that are highly correlated with recent sales fluctuations. This ensures the model's ability to adapt to new patterns while reducing the computational resource consumption of the model iteration process, shortening the model update time, and avoiding the prediction service interruption problem caused by full retraining.
[0016] Compared with existing technologies, the beneficial effects of this invention are: This invention employs a multi-scale decomposition-integration time-series forecasting architecture. It decomposes sales time series into three components: trend, cycle, and residual. Each component is matched with a corresponding adaptive model for hierarchical modeling. Simultaneously, it constructs multi-time-granularity forecasting sub-models. Through bidirectional consistency verification and adaptive weighted fusion, the final forecasting result is generated. This effectively solves the shortcomings of existing technologies, such as the poor adaptability of single statistical or deep learning models to the nonlinear effects of external covariates and the inability of single-granularity modeling to simultaneously consider long-term trend stability and short-term volatility sensitivity. This significantly improves the accuracy of full-cycle sales forecasting and its adaptability to complex scenarios.
[0017] This invention utilizes a dynamic threshold calculation logic that integrates predicted confidence intervals, historical fluctuation characteristics, and the intensity of current marketing activities. It adaptively adjusts the threshold leniency based on the model's real-time prediction performance, replacing the traditional fixed threshold or fixed confidence interval anomaly detection method. This effectively solves the shortcomings of existing technologies, such as weak scenario adaptability of early warning rules, high false alarm rate of normal sales fluctuations during the activity period, and high missed alarm rate of minor anomalies during off-peak periods. It significantly reduces the number of invalid early warnings and improves the accuracy of anomaly identification.
[0018] This invention transforms the abnormal handling results reported by front-line operations into labeled and effective incremental samples through a closed-loop early warning system and a lightweight model iteration mechanism. It updates model parameters by using incremental training combined with transfer learning for fine-tuning. This allows for rapid adaptation to dynamic changes in business models and consumption habits without the need for full retraining. It effectively solves the shortcomings of existing technologies, such as rapid accuracy decay over time after one-time model training and deployment, high computational cost of full retraining, and easy interruption of prediction services, thus ensuring the stability and accuracy of the system in the long term. Attached Figure Description
[0019] Figure 1 This is a flowchart of the overall sales forecasting and anomaly early warning system based on time series analysis proposed in this invention. Figure 2 This is a flowchart illustrating the time-series data preprocessing and standardized sample set generation process of this invention. Figure 3 This is a flowchart of the multi-scale fusion decomposition and integration time series prediction process of the present invention; Figure 4 This is a flowchart illustrating the dynamic threshold construction and anomaly warning level classification of the present invention; Figure 5 This is a flowchart of the early warning closed-loop handling and system model iterative update process of the present invention. Detailed Implementation
[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0021] Reference Figures 1 to 5 This invention discloses a sales forecasting and anomaly early warning system based on time series analysis, including a multi-source data access unit, a time series data preprocessing unit, a multi-scale fusion time series forecasting unit, a dynamic threshold anomaly early warning unit, and an early warning closed-loop processing unit.
[0022] The multi-source data access unit connects to five types of data sources: offline store POS transaction systems, e-commerce platform open interfaces, dealer warehouse management systems, omni-channel marketing activity management platforms, and databases of public holidays and local festivals. It uses a Kafka message queue to handle high-priority real-time transaction data and a timed batch retrieval method to synchronize low-priority inventory and festival-related static data. All accessed data is uniformly calibrated to UTC+8 standard time, and millisecond-level timestamp alignment is completed with a minimum statistical granularity of 1 minute. Points with clock deviations exceeding 100ms are automatically marked with time calibration tags. Finally, the data is written to a distributed time-series database using the Gorilla time-series compression algorithm. The end-to-end latency of data access is controlled within 5 seconds, fundamentally solving the problems of prediction lag and inconsistent time dimensions of multi-source data caused by T+1 batch data retrieval in traditional systems. The time series data preprocessing unit performs intelligent missing value completion, non-stationary noise smoothing, and time series stationarity ADF verification on the raw time series data entering the database in sequence. It labels each time series sample point with covariate labels and data confidence labels, and generates a standardized time series sample set covering all SKUs and all store dimensions. This eliminates the interference of raw data quality defects such as missing values, noise, and non-stationarity on the modeling accuracy from the data layer.
[0023] The multi-scale fusion time-series forecasting unit adopts a decomposition-integration parallel modeling architecture, building forecasting sub-models at three time granularities: daily, weekly, and monthly. After bidirectional consistency verification and adaptive weighted fusion, it outputs sales forecasts covering the entire cycle from 1 day to 90 days. At the same time, it outputs point-by-point 95% confidence intervals through quantile regression, meeting the decision-making needs of different levels such as store replenishment, regional inventory transfer, and headquarters capacity planning. This solves the problem that traditional single-scale forecasting cannot take into account both long-term trend stability and short-term volatility sensitivity.
[0024] The bidirectional consistency check adopts the execution order of "first top-down trend constraint, then bottom-up fluctuation supplementation", and the specific rules are as follows: Trend constraint validation (monthly → weekly → daily): First validate the monthly and weekly models, then validate the weekly and daily models. Taking the weekly model as an example: sum the weekly sales figures predicted for each week of the month to obtain the aggregated monthly value. Directly predicted values from monthly models In comparison, if the relative deviation exceeds 10%, the weekly forecast value is scaled proportionally, using the following formula:
[0025] in This is the predicted value for week i before scaling. This is the scaled value. The scaling logic for the daily model is the same as that for the weekly model.
[0026] Fluctuation Supplement Validation (Daily → Weekly → Monthly): If the daily model captures short-term fluctuations caused by recent marketing activities or sudden public events, and the weekly and monthly models do not include the impact of this factor, then the relevant time period forecast values of the low-granularity model should be adjusted accordingly to improve the sensitivity of long-term forecasts to sudden sales fluctuations.
[0027] The dynamic threshold anomaly early warning unit combines point-by-point prediction confidence intervals, historical fluctuation patterns, and current activity scenarios to construct anomaly judgment thresholds that dynamically adjust over time. It performs anomaly verification on real-time collected sales data every minute, and determines fluctuations where two consecutive statistical points exceed the threshold as valid anomalies. Based on the fluctuation deviation magnitude, it matches three levels of early warning and automatically generates standardized early warning work orders containing point ID, actual value, predicted value, deviation degree, and associated triggers. This solves the problems of poor adaptability and high false alarm and missed alarm rates of traditional fixed threshold early warning scenarios.
[0028] The early warning closed-loop handling unit pushes early warning information through multiple channels such as WeChat, system in-site messages, and SMS according to the response link corresponding to the early warning level. It records the verification actions, root causes of anomalies, handling measures and effects of each response end throughout the process. The incremental samples formed by the handling feedback are stored in the time series sample library. The model parameters are triggered to iterate according to the set rules to achieve continuous self-optimization of prediction accuracy and early warning accuracy. This solves the problem of traditional systems having no closed loop after going online and the model accuracy gradually decreasing with changes in business.
[0029] This invention also discloses the missing value completion logic of the time series data preprocessing unit. When performing missing value completion, the continuous missing duration of each time series segment is first identified. For short-term missing segments with a continuous missing duration of less than 3 statistical granularities, a time-distance weighted sliding window interpolation method is used to complete the completion. The interpolation result of the point to be completed is obtained by weighting the values of two adjacent valid time series points. The weight is inversely proportional to the time distance from the point to be completed to the valid point; the closer the distance, the higher the weight. For long-term missing segments with a continuous missing duration of more than 3 statistical granularities, the Pearson correlation coefficient is first used to match a set of related stores with the same product category structure, the same business district level, and the same business scale. Stores with a historical sales correlation greater than 0.8 are selected, and the weighted average of the sales of the related stores during the same period is taken as the completion value.
[0030] During the completion process, a confidence weight between 0 and 1 is assigned to each completion point based on the historical accuracy of the completion method. The confidence weight of points completed by short-time interpolation is set to 0.8-0.9. The confidence weight of points completed by association mapping is positively correlated with the relevance of the associated stores. A relevance of 0.9 or above corresponds to a weight of 0.7, and a relevance of 0.8 corresponds to a weight of 0.6. In the subsequent model training stage, the confidence weight is used as the weighting coefficient of the sample loss. The lower the confidence of the sample, the smaller the impact on the model parameter update. This reduces the interference of missing value completion bias on the model accuracy from the source and solves the problem of insufficient accuracy of traditional unified interpolation methods for long-term missing value completion.
[0031] This invention also discloses the noise smoothing logic of the time-series data preprocessing unit. After completing the missing value completion, a sliding window discrete wavelet transform is used to remove impulse outlier noise in the sales time series. The wavelet basis is selected as the db4 orthogonal wavelet, which matches the autocorrelation length of the retail sales cycle fluctuation. The number of wavelet decomposition layers is adaptively set according to the current time-series statistical granularity: daily granular data has a high sampling frequency and a large noise ratio, so 4 layers of decomposition are set; weekly granular data has been aggregated on a weekly dimension and the fluctuation is smoother, so 3 layers of decomposition are set; monthly granular data has the highest aggregation degree and the smallest noise ratio, so 2 layers of decomposition are set.
[0032] The threshold quantization process employs a soft threshold function to process high-frequency wavelet coefficients. High-frequency coefficients below the adaptive threshold are set to zero, while coefficients above the threshold are retained after being shrunk towards zero. The adaptive threshold uses a general threshold calculation method (VisuShrink threshold), calculated independently for each layer of high-frequency wavelet coefficients. The formula is as follows: ;in, The noise standard deviation of the high-frequency wavelet coefficients of the current layer is estimated using the median absolute deviation method: , This is the high-frequency wavelet coefficient sequence of the current layer. The threshold is the length of the wavelet coefficients in the current layer. This threshold is dynamically adjusted according to the distribution of wavelet coefficients in the current sliding window, which can achieve asymptotically optimal denoising effect in Gaussian white noise scenarios. Finally, the denoised time series signal is obtained through wavelet reconstruction. The long-term trend component, seasonal cycle component and random fluctuation residual component corresponding to the real sales are separated and retained to avoid impulse noise points being misjudged as abnormal sales fluctuations and reduce invalid false alarms in subsequent early warning links.
[0033] This invention also discloses the decomposition-integration modeling logic of a multi-scale fusion time-series prediction unit. For the sales time series at each time granularity, a robust STL time-series decomposition method is first used to perform hierarchical splitting. The core parameters are adaptively configured according to the seasonal cycle length of the corresponding time granularity: seasonal cycle: matching the business fluctuation cycle, with daily granularity set to 7 days (weekly cycle), weekly granularity set to 4 weeks (monthly cycle, corresponding to 28 days), and monthly granularity set to 12 months (annual cycle); Seasonal window length: take an odd number to smooth in-phase seasonal subsequences. The daily granularity is 7, the weekly granularity is 3, and the monthly granularity is 13. The window size matches the period length and the sample size of the subsequence. Trend window length: Take the smallest odd number that is greater than 1.5 times the length of the seasonal cycle to ensure that the trend components are not affected by seasonal fluctuations, i.e., the daily granularity is 11, the weekly granularity is 7, and the monthly granularity is 19. Iteration parameters: The inner loop iteration count is set to 2, and the outer loop robust iteration count is set to 3. During the iteration process, outliers are automatically assigned low weights to avoid extreme values interfering with the decomposition results. Finally, the time series is decomposed into long-term trend components, seasonal cycle components, and random residual components.
[0034] The long-term trend component is used to capture the long-term variation of sales volume with business development. It is modeled using a linear trend extrapolation model with an L2 regularization term, where the regularization coefficient is set to 0.01 to prevent overfitting to short-term fluctuations. The seasonal cycle component is used to capture the influence of fixed-cycle fluctuations and external covariates such as holidays, marketing activities, and weather. It is modeled using a lightweight temporal convolutional network with a covariate embedding layer. The network structure consists of three causal convolutional layers with kernel sizes of 3 and inflation coefficients of 1, 2, and 4. The covariate embedding layer converts categorical covariates into 8-dimensional dense embedding vectors, which are then concatenated with numerical time-series features before being input into the convolutional layer to capture the non-linear relationship between covariates and sales fluctuations. The random residual component is used to capture random fluctuations that cannot be explained by the first two components. It is modeled using a seasonal autoregressive moving average (SARIMA) model, with the complete parameter form as follows: The non-seasonal parameters p (autoregressive order), d (difference stratification), and q (moving average order) are automatically selected within the range of 0-3 using the AIC criterion. The seasonal parameters P (seasonal autoregressive order), D (seasonal difference stratification), and Q (seasonal moving average order) are automatically selected within the range of 0-2 using the AIC criterion. The seasonal period m is set according to the time granularity, with daily granularity set to 7 days, weekly granularity set to 4 weeks, and monthly granularity set to 12 months.
[0035] The initial weights of the three components are set to 0.5, 0.4, and 0.1 based on the historical fitting accuracy. After each training cycle, the weights are dynamically adjusted based on the independent prediction error of each component. The smaller the error, the higher the weight of the component. Finally, the weighted output of the three components is used as the preliminary prediction value under a single scale, realizing hierarchical modeling of different fluctuation patterns and solving the problem that a single model is not capable of fitting complex sales time series.
[0036] This invention also discloses the cross-scale fusion logic of the multi-scale fusion time series prediction unit. After the three parallel prediction sub-models of daily, weekly, and monthly output the preliminary prediction results, the deviation correction is first carried out through the bidirectional consistency verification module: the low-granularity monthly model provides long-term trend constraints for the high-granularity daily and weekly models. If the monthly sales summary value predicted by the weekly model deviates from the monthly model prediction value by more than 10%, the prediction value of the weekly model is scaled proportionally to ensure that the long-term trend does not show directional deviation. The high-granularity daily model supplements the low-granularity weekly and monthly models with details of short-term fluctuations. If the daily model captures short-term fluctuations caused by recent marketing activities or sudden public events, and the weekly and monthly models do not include the impact of these factors, then the relevant time-period forecast values of the low-granularity model are adjusted accordingly to improve the sensitivity of long-term forecasts to sudden fluctuations. After verification, the final sales forecast value at time t is obtained through adaptive weighted fusion. The fusion calculation satisfies the following relationship: This computational logic is applied to the integration of multi-time-granularity prediction results, ensuring that the fused results simultaneously consider both long-term trend stability and short-term volatility sensitivity. for The final sales forecast at any given time is measured in units of the number of units sold at the corresponding statistical granularity. for Moment corresponds to time scale The model output weights are dimensionless parameters, ranging from 0 to 1, and the sum of the weights of the three scales at the same time is always 1. The time scale identifier, with a value of 'd' representing a daily granularity prediction sub-model, and a value of [value missing]... The value 'm' represents the weekly granularity prediction sub-model, while the value 'm' represents the monthly granularity prediction sub-model. Time scale The output of the sub-model The sales forecast value at time t is measured in the number of units sold. The weights are dynamically allocated based on the average absolute percentage error of the predictions over the 12 sliding statistical periods preceding time t for each scale model. The unit of the 12 sliding statistical periods corresponds to the time granularity of the corresponding sub-model: 12 calendar days for the daily model, 12 calendar weeks for the weekly model, and 12 calendar months for the monthly model. The weights are calculated using the reciprocal of the error, and the specific formula is as follows: ;in, The average absolute percentage error of the sub-model corresponding to time scale s within the first 12 sliding cycles before time t is calculated through normalization. The sum of the weights of the three scales is always 1. The model with higher accuracy has a larger weight, so as to achieve the synergistic effect of the prediction advantages of different granularities.
[0037] This invention also discloses the threshold calculation logic of the dynamic threshold anomaly early warning unit. When constructing the discrimination threshold, the traditional fixed-ratio threshold logic for all time periods is abandoned. Instead, the sales forecast value at each time point is used as a benchmark, combined with the prediction confidence interval width, the variance of historical sales fluctuations in the same period, and the expected fluctuation of marketing activities in the current period, to calculate the upper and lower discrimination thresholds that dynamically fluctuate over time. The threshold calculation satisfies the following relationship: This calculation logic is applied to the real-time identification of abnormal sales fluctuations, replacing the traditional fixed threshold discrimination method, dynamically adapting to the fluctuation characteristics under different scenarios, and balancing the false alarm rate and false negative rate of abnormal identification.
[0038] in , They are respectively The upper and lower thresholds for anomaly detection at any given time represent... The upper and lower boundaries of normal sales fluctuations at any given time, measured in the number of units sold. for The threshold sensitivity adjustment coefficient at any given time is a dimensionless parameter, ranging from 1.5 to 3. It is adaptively adjusted based on the model prediction accuracy over nearly 30 statistical periods; the higher the prediction accuracy, the more sensitive the threshold sensitivity adjustment. The smaller the value and the stricter the threshold, the lower the prediction accuracy. The larger the value, the more lenient the threshold discrimination; for The standard deviation of the predicted value output by the time-based prediction model is used to characterize the uncertainty of the prediction result at the current location, and the unit of measurement is the number of goods sold. for The standard deviation of sales fluctuations for the same period in history corresponds to three sales cycles, representing the natural fluctuation range of the same period in history, and the unit of measurement is the number of units sold. for The standard deviation of expected sales fluctuation corresponding to a marketing campaign at any given moment is calculated based on the campaign's discount level, traffic investment scale, and historical sales fluctuations of similar campaigns. The unit of measurement is the number of units sold. (No marketing campaign is included.) When the value is 0, it indicates that an S-level omnichannel promotion is being conducted. The value is the mean standard deviation of sales fluctuations in similar historical promotional events. , , The weights for the three influencing factors—prediction uncertainty, historical volatility, and activity volatility—are dimensionless parameters determined through grid search and fitting of historical data. Specifically, the following method is used: Six months of historical sales data and labeled anomaly samples are selected as the training set; a grid search is performed with a step size of 0.05 under the constraint of α+β+γ=1; the F1 score of anomaly identification is used as the optimization objective, and the weight combination with the highest F1 score is selected as the initial value; after the system is running, the weights are refitted quarterly based on newly added early warning feedback samples to achieve dynamic optimization; the sum of the three factors is always 1, and the initial values are set to 0.5, 0.3, and 0.2.
[0039] This invention also discloses the warning level matching logic of the dynamic threshold anomaly warning unit. After completing the threshold calculation, the real-time collected actual sales value is compared with the corresponding dynamic threshold, and the relative deviation ratio is calculated, that is, the ratio of the absolute difference between the actual value and the predicted value to the predicted value. Based on the deviation magnitude, it is divided into three warning levels: If the deviation is in the first range, that is, the actual value exceeds the threshold but the relative deviation ratio is less than 20%, it is judged as a general warning. The corresponding work order is pushed to the store operation end, with a 24-hour response time set, to remind the store operation staff to conduct daily sales anomaly verification. If the deviation is in the second range, that is, the relative deviation ratio is between 20% and 50%, it is considered an important warning. The corresponding work order is pushed to the regional operation management terminal, with a 4-hour response time limit, prompting regional managers to carry out regional-level supply scheduling and marketing effect review. If the deviation is in the third range, i.e., the relative deviation ratio is higher than 50%, an emergency warning is issued. The corresponding work order is pushed to the supply chain management and marketing decision-making end, with a 1-hour response time limit, prompting key decision-makers to carry out full-chain inventory adjustments and marketing plan optimizations.
[0040] All early warning work orders are automatically associated with corresponding scene tags. If the early warning period matches known covariates such as marketing activities or sudden weather changes, the work order will simultaneously indicate the suspected cause, reducing the workload of frontline staff and enabling precise allocation of early warning resources, thus avoiding non-core anomalies from occupying too many decision-making resources.
[0041] This invention also discloses the conventional iterative logic of the early warning closed-loop handling unit. After receiving the early warning handling result from the front-line terminal, the system first performs structured parsing on the feedback content, extracts core information such as the actual sales value of the corresponding early warning point, the root cause of the anomaly, the specific handling measures taken, and the sales change trend after handling, and stores the verified valid information as a new tagged sample in the time series sample library; For false anomalies reported as entry errors or system malfunctions, the system automatically corrects the corresponding erroneous data in the time-series database to prevent erroneous data from interfering with subsequent model training. For samples reported as genuine sudden anomalies, corresponding event labels are added to help the model learn fluctuation patterns under specific scenarios. The system triggers incremental training of the multi-scale fusion time-series prediction unit at a fixed weekly cycle, using newly added samples from the past three months to fine-tune the model's output layer parameters. The learning rate during training is set to 0.001, one-tenth of the initial training learning rate, to prevent the model from forgetting historical patterns. Simultaneously, the dynamic threshold calculation process is recalibrated based on the warning accuracy rate of the most recent quarter. , , Weight values enable the model to quickly adapt to recent changes in sales patterns, continuously improving the matching degree between prediction results and actual business scenarios.
[0042] This invention also discloses the implementation logic of a configurable visual interaction unit. The visual interaction unit uses the ECharts front-end component library to build a multi-dimensional display interface. The core display modules include a line chart of the historical trend of full sales volume, a multi-period prediction curve chart with 95% confidence interval shading, and a spatial distribution map of abnormal warning points. The spatial distribution map is implemented as a scatter plot layer based on the Gaode Map API, and the size and color of the scatter plots correspond to the warning level.
[0043] The interface allows users to customize and adjust the prediction time range and alert threshold sensitivity parameters according to their management needs. The sensitivity slider can be dragged to adjust the sensitivity in real time. Value retrieval allows for simultaneous preview of threshold range changes; it supports drill-down viewing of sales details, historical alert records, and handling results by category, sales region, and store level, maintaining consistency in data time granularity during drill-down. Users can manually mark special sales events on the trend chart, adding labels such as event type, duration, and scope of impact. The marked content is automatically synchronized to the covariate database, supplementing the model training with manually labeled scene labels, further improving the model's ability to identify special events.
[0044] This invention also discloses the trigger-based model fine-tuning logic of the early warning closed-loop handling unit. In addition to weekly fixed incremental training, the system employs a dual-trigger mechanism to initiate full-scale model parameter fine-tuning: when the cumulative number of newly added valid samples in the time-series sample library reaches 1000, or when the overall average absolute percentage error of the model's predictions over three consecutive prediction periods exceeds 20%, the fine-tuning process is automatically triggered as long as either condition is met. The fine-tuning process adopts a transfer learning approach, freezing the parameters of the first two shallow layers of the temporal convolutional network (corresponding to the ability to extract general sales trends and cyclical patterns), and only updating the top-level network parameters of the last convolutional layer and the fully connected output layer. The training computation is only 20% of that of full retraining, and the model update time is reduced from 2 hours to less than 20 minutes.
[0045] After fine-tuning, a canary release strategy was adopted to switch the model service. First, 10% of prediction requests were diverted to the new model. Once the accuracy of the new model was verified to be no lower than the old model, a full switch was completed. The entire switch process was uninterrupted, ensuring the model's adaptability to new patterns while reducing the computational resource consumption of model iterations and avoiding prediction service interruptions caused by full retraining. During the initial training phase, historical time-series data from the past two years were used, divided into training, validation, and test sets in an 8:1:1 ratio. The loss function used was quantile loss with sample weights, the optimizer was AdamW, and the batch size was set to 32. An early stopping strategy was employed to prevent overfitting; training was terminated when the validation set loss did not decrease for 10 consecutive rounds.
[0046] Reference Figure 1 This flowchart illustrates the overall operational logic of a sales forecasting and anomaly early warning system based on time-series analysis. The system first collects multi-source data in real time, including terminal sales, inventory turnover, and marketing activities, through a multi-source data access unit, and stores the data in a time-series database after aligning with timestamps and standardizing the data. Subsequently, the preprocessing unit performs missing value completion, noise smoothing, and stationarity checks on the raw data stream, generating a high-quality standardized sample set with covariate labels. The multi-scale fusion time-series forecasting unit, based on a decomposition-integration architecture, models multi-granularity time series to output sales forecast values and confidence intervals. Next, the early warning unit combines the forecast results to construct dynamic anomaly detection thresholds, identify abnormal fluctuations, and generate standardized early warning work orders of different levels. Finally, the early warning closed-loop handling unit completes the handling closed loop based on front-end feedback and drives adaptive iterative optimization of the system model parameters.
[0047] Reference Figure 2This flowchart details the execution steps of time-series data preprocessing. In the missing value completion stage, for time segments with consecutive missing values less than a set threshold, the system uses an adjacent time-series sliding weighted interpolation method; for time segments exceeding the threshold, sales correlation mapping values from stores of the same product category and location are introduced for completion, and the reliability weight of each point is simultaneously and accurately marked. After entering the noise smoothing stage, the system applies sliding window wavelet transform technology, selects a specific wavelet basis matching the cyclical fluctuations of sales, and adaptively adjusts the number of decomposition levels. This effectively filters out outlier impulse noise caused by promotional order entry deviations or counting errors, accurately retains trend components, cyclical components, and residual components reflecting the actual business operation, and finally outputs a standardized sample set for subsequent modeling.
[0048] Reference Figure 3 This flowchart illustrates the specific computational mechanism of multi-scale fusion time series forecasting. The system adopts a decomposition-integration architecture, first using a time series decomposition method to separate sales time series into three independent components: trend, cycle, and residual. The trend component is modeled using linear trend extrapolation, the cycle component is modeled using a time series convolutional network in conjunction with covariates such as holidays, and the residual component is processed using an autoregressive moving average model. The three outputs are adaptively weighted and fused to obtain the preliminary predicted values for the corresponding nodes. Based on this architecture, the system establishes prediction sub-models for three time granularities: daily, weekly, and monthly. The prediction results at different granularities then enter a consistency verification module to correct deviations. The low-granularity model provides long-term constraints, while the high-granularity model supplements short-term details, outputting continuous prediction results covering the entire cycle.
[0049] Reference Figure 4 This flowchart illustrates the logic behind the construction of dynamic thresholds and the classification of abnormal warning levels. The system abandons traditional fixed thresholds, instead using predicted values at various time points as a benchmark. It integrates the prediction confidence interval width, historical variance of fluctuations in the same period, and the intensity coefficient of the current marketing campaign to calculate dynamically fluctuating upper and lower thresholds. The system adaptively adjusts the threshold's leniency based on recent prediction accuracy. When actual monitored sales deviate from the dynamic boundaries, the system precisely classifies them into three warning levels based on the magnitude of the deviation. Deviations within the first interval trigger a general warning and are pushed to the store operations end; deviations between the first and second intervals trigger an important warning and are pushed to the regional management end; deviations exceeding the second interval are judged as emergency warnings, and are immediately synchronized to the supply chain and marketing decision-making ends for differentiated intervention.
[0050] Reference Figure 5This flowchart illustrates the workflow of closed-loop early warning processing and incremental iteration of the system model. The closed-loop processing unit continuously receives feedback from the front-line regarding the handling of early warning work orders, adding actual sales, causes of anomalies, and corresponding measures as new valid samples to the time-series sample library. When an update is triggered according to a predetermined cycle, or when the number of new valid samples reaches the capacity threshold, or when the prediction accuracy falls below the safety lower limit for several consecutive cycles, the system will automatically initiate incremental training of the model parameters. During this fine-tuning process, the system fully retains the general trend extraction network parameters solidified in previous historical training, updating only the shallow network parameters closely related to recent sales fluctuations. This mechanism ensures that the early warning model adapts to changes in business scenarios while significantly reducing the computational resource overhead of iterative optimization.
[0051] The above are merely preferred embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A sales forecasting and anomaly early warning system based on time series analysis, characterized in that, It includes a multi-source data access unit, a time-series data preprocessing unit, a multi-scale fusion time-series prediction unit, a dynamic threshold anomaly early warning unit, and an early warning closed-loop processing unit; The multi-source data access unit is used to collect multi-source heterogeneous time-series data streams. It uses millisecond-level timestamp calibration to achieve unified time granularity alignment of data from different sources. It is then standardized and stored in a distributed time-series database through the TSDB compression engine, with end-to-end data latency controlled within 5 seconds. The time series data preprocessing unit is used to perform confidence-weighted missing value completion, db4 wavelet-based sliding window discrete wavelet transform noise smoothing, and ADF time series stationarity verification on the acquired raw time series data stream, generating a standardized time series sample set with covariate labels and confidence labels. The multi-scale fusion time series prediction unit adopts a decomposition-integration architecture, performs hierarchical modeling of sales time series at different time granularities, and outputs sales prediction values and corresponding prediction confidence intervals covering short, medium and long periods after bidirectional consistency verification and adaptive weighted fusion. The dynamic threshold anomaly early warning unit combines the prediction confidence interval, historical fluctuation variance, and marketing activity intensity coefficient to construct an anomaly discrimination threshold model that dynamically adjusts over time, identifies abnormal sales fluctuations that exceed the threshold range, and generates standardized early warning work orders by matching the corresponding early warning level. The early warning closed-loop processing unit is used to push early warning information according to the early warning level, record the processing feedback results, and use a transfer learning mechanism to freeze the underlying general feature parameters and only update the top-level network parameters to achieve lightweight iterative updates of the model.
2. The sales forecasting and anomaly early warning system based on time series analysis according to claim 1, characterized in that, When the time series data preprocessing unit performs missing value completion, for time series segments with consecutive missing durations less than a set threshold, the adjacent time series sliding weighted interpolation method is used to complete the completion; for time series segments with consecutive missing durations exceeding the threshold, the sales time series association mapping values of stores of the same category and location are introduced to complete the completion. During the completion process, the credibility weight of each completion point is marked simultaneously for weighted calling in the subsequent modeling stage.
3. The sales forecasting and anomaly early warning system based on time series analysis according to claim 2, characterized in that, When the time series data preprocessing unit performs noise smoothing after completing missing value completion, it uses sliding window wavelet transform to remove impulse noise in the sales time series. The wavelet basis is selected as the db4 wavelet, which matches the cyclical fluctuation characteristics of sales. The number of decomposition layers is adaptively adjusted according to the current processing time series granularity. It filters out outlier noise points caused by promotional order entry deviation and system counting errors, and retains the trend component, cyclical component and residual component corresponding to the actual sales.
4. The sales forecasting and anomaly early warning system based on time series analysis according to claim 1, characterized in that, The decomposition-integration architecture of the multi-scale fusion time series prediction unit first decomposes the preprocessed sales time series into trend components, periodic components, and residual components using the STL time series decomposition method. The trend component is modeled using a linear trend extrapolation model, the periodic component is modeled using a time series convolutional network in combination with covariates of holidays and marketing activities, and the residual component is modeled using a seasonal autoregressive moving average model. The outputs of the three components are adaptively weighted and fused to obtain the sales prediction value at the corresponding time point.
5. The sales forecasting and anomaly early warning system based on time series analysis according to claim 4, characterized in that, The multi-scale fusion time series prediction unit constructs prediction sub-models for three time granularities: daily, weekly, and monthly. The prediction results of adjacent granularities are corrected for deviations through a consistency verification module. The low-granularity model provides long-term trend constraints for the high-granularity model, while the high-granularity model supplements short-term fluctuation details for the low-granularity model, outputting continuous prediction results covering the entire short, medium, and long cycle.
6. The sales forecasting and anomaly early warning system based on time series analysis according to claim 1, characterized in that, When constructing the discrimination threshold, the dynamic threshold anomaly early warning unit uses the sales forecast value at each time point as a benchmark, combined with the prediction confidence interval width at the corresponding time point, the historical sales fluctuation variance, and the standard deviation of the marketing activity fluctuation in the current period, to calculate the dynamically floating upper and lower discrimination thresholds, replacing the traditional fixed threshold discrimination logic. During the threshold calculation process, the threshold leniency is adaptively adjusted according to the model prediction accuracy of the most recent sliding cycle.
7. The sales forecasting and anomaly early warning system based on time series analysis according to claim 6, characterized in that, When the dynamic threshold anomaly warning unit matches the warning level, it divides the deviation of the sales value from the dynamic threshold into three levels. The deviation is in the first range, which is a general warning and is pushed to the store operation end; the deviation is between the first and second ranges, which is an important warning and is pushed to the regional management end; and the deviation exceeds the second range, which is an emergency warning and is pushed to the supply chain management and marketing decision-making end. Different levels of warnings are set with different response time requirements.
8. The sales forecasting and anomaly early warning system based on time series analysis according to claim 1, characterized in that, When the early warning closed-loop handling unit iteratively updates the model parameters, it stores the actual sales value, the cause of the anomaly, and the handling measures taken corresponding to the received early warning handling feedback as new valid samples in the time series sample library. It triggers the incremental training of the multi-scale fusion time series prediction unit according to the set update cycle, and synchronously corrects the calculation parameters of the dynamic threshold to realize the adaptive optimization of the model as the business scenario changes.
9. The sales forecasting and anomaly early warning system based on time series analysis according to claim 1, characterized in that, It also includes a visualization and interactive unit, which is used to display the historical trend of sales time series, multi-period prediction curves, and spatial distribution of abnormal warning points in multiple dimensions. It supports users to customize and adjust the prediction time range and warning threshold sensitivity parameters, and supports drill-down to view the corresponding sales details and warning records by category, region, and store.
10. The sales forecasting and anomaly early warning system based on time series analysis according to claim 8, characterized in that, When the early warning closed-loop handling unit triggers incremental model training, if the cumulative number of newly added effective samples reaches the set sample capacity threshold, or the model prediction accuracy for three consecutive prediction periods is lower than the set accuracy threshold, it automatically triggers full parameter fine-tuning of the model. During the fine-tuning process, the general trend extraction parameters obtained from historical model training are retained, corresponding to the first two shallow layers of the temporal convolutional network; only the top layer network parameters that are highly correlated with recent sales fluctuations are updated, corresponding to the last convolutional layer and the fully connected output layer; thus reducing the computational resource consumption during the model iteration process.
