Garment sales volume prediction method and system based on improved Transform model

By introducing a trend coding matrix into the Transformer model and replacing the position coding matrix, the problem of multi-head distraction in trend analysis is solved, and the accuracy and adaptability of clothing sales forecasts are improved.

CN119313388APending Publication Date: 2025-01-14ZHIYI TECH +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411369146.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

In sales forecasting, since the focus is context semantic analysis, directly referring to the position coding matrix will cause the bulls to be distracted and affect the prediction effect, especially in terms of trend analysis.

Method used

Introduce a trend coding matrix, calculate the mean, maximum and minimum values ​​of sales characteristics, calculate the difference between each feature point and the mean, and perform normalization and vectorization expression to replace the original position coding matrix to better Capture trend information of sales data.

Benefits of technology

The improved Transformer model better adapts to sales forecasting tasks, corrects bullish attention, and improves prediction effect and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119313388A_ABST
    Figure CN119313388A_ABST
Patent Text Reader

Abstract

The invention discloses a clothing sales volume prediction method and system based on an improved Transform model. The method comprises the following steps: acquiring a clothing sales volume data set; dividing the clothing sales data set to obtain a training set, a verification set and a test set; an improved Transform model is constructed, the improved Transform model comprises a trend coding matrix, and the trend coding matrix is used for carrying out trend coding on the input sales volume characteristics; and training the constructed improved Transform model through the clothing sales volume data set, and outputting a clothing sales volume prediction result through the trained improved Transform model. According to the garment sales volume prediction method and system based on the improved Transform model, the Transform model is improved, an original position coding matrix is removed, a new trend coding matrix is added, and multi-head attention is corrected, so that the multi-head attention better falls on a data trend and better adapts to a sales prediction task.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention specifically relates to a clothing sales forecasting method and system based on an improved Transformer model. Background Art

[0002] The powerful sequence modeling capability of the Transformer model has made it widely used in sales forecasting. The application of the Transformer model in sales forecasting has brought significant improvements and innovations, mainly reflected in the following aspects: 1. Capturing long-range dependencies: The Transformer model uses a self-attention mechanism to effectively capture long-range dependencies in sequence data. Compared with traditional RNN and LSTM models, Transformer can better handle sales data with a long time span. 2. Parallel computing: The Transformer model can perform parallel computing instead of relying on sequential computing like RNN. This greatly improves the speed of model training and prediction, and can process large-scale sales data faster. 3. Processing multivariate time series data: The Transformer model can process multivariate time series data, including multiple factors such as price, promotion, inventory, holidays, etc. This multivariate feature allows the model to consider more influencing factors when predicting sales volume and improve prediction accuracy. 4. Flexibility and scalability: The Transformer model has high flexibility and scalability, and can be adjusted and expanded according to different business needs.

[0003] However, the Transformer model focuses on semantic analysis of the context, so a position encoding matrix is ​​needed to introduce the position information of the word in the sentence. The sales volume feature focuses on trend analysis, and directly referencing the original Transformer position encoding matrix will cause multiple attentions to be dispersed, affecting the prediction effect. Summary of the invention

[0004] The present invention provides a clothing sales forecasting method and system based on an improved Transformer model to solve the above-mentioned technical problems, and specifically adopts the following technical solutions:

[0005] A clothing sales prediction method based on an improved Transformer model, including:

[0006] Get the clothing sales data set;

[0007] The clothing sales data set is divided into training set, validation set, and test set;

[0008] Constructing an improved Transformer model, wherein the improved Transformer model includes a trend encoding matrix, and the trend encoding matrix is ​​used to perform trend encoding on the input sales volume features;

[0009] The constructed improved Transformer model is trained through the clothing sales data set, and the clothing sales prediction results are output through the trained improved Transformer model.

[0010] Furthermore, the specific method of the trend coding matrix for trend coding the input sales features is as follows:

[0011] For a given set of sales features x = [x1, x2, x3, ...],

[0012] Calculate the mean, maximum, and minimum values ​​of the sales feature:

[0013]

[0014] m=min(x)

[0015] M=max(x)

[0016] Calculate the difference between each feature point in the sales feature and the mean.

[0017]

[0018] Among them, if the difference is negative, it means that the trend of this point is downward, and if the difference is positive, the trend is upward;

[0019] Normalize the differences that represent the trend:

[0020]

[0021] Get the normalized result:

[0022]

[0023] The normalized results are expressed as trend vector matrix.

[0024] Furthermore, nn.Embedding is used to express the trend vectorized matrix.

[0025] Furthermore, the clothing sales data set is divided into training set, validation set, and test set in a ratio of 7:2:1.

[0026] Furthermore, the data in the clothing sales data set includes actual sales data for each month in previous years.

[0027] A clothing sales prediction system based on an improved Transformer model, including:

[0028] Data acquisition module, obtains clothing sales data set;

[0029] The data processing module is used to divide the clothing sales data set into a training set, a validation set, and a test set;

[0030] A model building module, used to build an improved Transformer model, wherein the improved Transformer model includes a trend coding matrix, and the trend coding matrix is ​​used to perform trend coding on input sales features;

[0031] The constructed improved Transformer model is trained through the clothing sales data set, and the clothing sales prediction results are output through the trained improved Transformer model.

[0032] Furthermore, the specific method of the trend coding matrix for trend coding the input sales features is as follows:

[0033] For a given set of sales features x = [x1, x2, x3, ...],

[0034] Calculate the mean, maximum, and minimum values ​​of the sales feature:

[0035]

[0036] m=min(x)

[0037] M=max(x)

[0038] Calculate the difference between each feature point in the sales feature and the mean.

[0039]

[0040] Among them, if the difference is negative, it means that the trend of this point is downward, and if the difference is positive, the trend is upward;

[0041] Normalize the differences that represent the trend:

[0042]

[0043] Get the normalized result:

[0044]

[0045] The normalized results are expressed as trend vector matrix.

[0046] Furthermore, nn.Embedding is used to express the trend vectorized matrix.

[0047] Furthermore, the clothing sales data set is divided into a training set, a validation set, and a test set in a ratio of 7:2:1 by the data processing module.

[0048] Furthermore, the data in the clothing sales data set acquired by the data acquisition module includes actual sales data of each month in previous years.

[0049] The benefit of the present invention lies in the provided clothing sales forecasting method and system based on the improved Transformer model, which improves the Transformer model by removing the original position coding matrix and adding a new trend coding matrix to correct the multi-head attention so that it can better focus on the data trend and better adapt to the sales forecasting task. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0051] Figure 1 is a schematic diagram of a clothing sales forecasting method based on an improved Transformer model of the present invention;

[0052] Figure 2 It is a schematic diagram of an improved Transformer model of the present invention. DETAILED DESCRIPTION

[0053] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0054] like Figure 1The present application shows a clothing sales prediction method based on an improved Transformer model, comprising: S1: obtaining a clothing sales data set. S2: dividing the clothing sales data set into a training set, a validation set, and a test set. S3: constructing an improved Transformer model, the improved Transformer model comprising a trend coding matrix, and the trend coding matrix is ​​used to perform trend coding on the input sales features. S4: training the constructed improved Transformer model through the clothing sales data set and outputting the clothing sales prediction result through the trained improved Transformer model. The present application's clothing sales prediction method based on an improved Transformer model improves the Transformer model, removes the original position coding matrix, adds a new trend coding matrix, corrects the multi-head attention, so that it can better focus on the data trend, and makes it better adapt to the sales forecasting task. The above steps are described in detail below.

[0055] For step S1: obtain a clothing sales data set.

[0056] In the implementation of the present application, the clothing sales data specifically obtained refers to the actual sales data of each month in previous years. The sales growth rate of the next month is predicted by learning its trend changes through the model.

[0057] S2: Divide the clothing sales data set into training set, validation set, and test set.

[0058] In an implementation of the present application, the clothing sales data set is divided into a training set, a validation set, and a test set in a ratio of 7:2:1.

[0059] S3: Build an improved Transformer model. Figure 2 As shown, the improved Transformer model includes a trend encoding matrix, which is used to perform trend encoding on the input sales features. This application improves the Transformer model by removing the original position encoding matrix and adding a new trend encoding matrix to correct the multi-head attention.

[0060] In the implementation manner of the present application, the specific method of the trend coding matrix for trend coding the input sales features is as follows:

[0061] For a given set of sales features x = [x1, x2, x3, ...],

[0062] Calculate the mean, maximum, and minimum values ​​of the sales feature:

[0063]

[0064] m=min(x)

[0065] M=max(x)

[0066] Calculate the difference between each feature point in the sales feature and the mean.

[0067]

[0068] Among them, if the difference is negative, it means that the trend of this point is downward, and if the difference is positive, the trend is upward.

[0069] Normalize the differences that represent the trend:

[0070]

[0071] Get the normalized result:

[0072]

[0073] The normalized results are expressed as trend vector matrix.

[0074] In an implementation of the present application, nn.Embedding is used to perform trend vectorization matrix expression.

[0075] The overall formula is as follows:

[0076]

[0077] S4: Train the constructed improved Transformer model through the clothing sales data set and output the clothing sales prediction results through the trained improved Transformer model.

[0078] The present application also discloses a clothing sales forecasting system based on an improved Transformer model, which is used to implement the aforementioned clothing sales forecasting method based on an improved Transformer model. The clothing sales forecasting system based on the improved Transformer model includes: a data acquisition module, a data processing module and a model building module.

[0079] The data acquisition module is used to obtain the clothing sales data set. The data processing module is used to divide the clothing sales data set into training set, validation set, and test set. The model construction module is used to construct an improved Transformer model. The improved Transformer model contains a trend encoding matrix, which is used to perform trend encoding on the input sales features. The constructed improved Transformer model is trained with the clothing sales data set and the clothing sales prediction results are output through the trained improved Transformer model.

[0080] In the implementation manner of the present application, the specific method of the trend coding matrix for trend coding the input sales features is as follows:

[0081] For a given set of sales features x = [x1, x2, x3, ...],

[0082] Calculate the mean, maximum, and minimum values ​​of the sales feature:

[0083]

[0084] m=min(x)

[0085] M=max(x)

[0086] Calculate the difference between each feature point in the sales feature and the mean.

[0087]

[0088] Among them, if the difference is negative, it means that the trend of this point is downward, and if the difference is positive, the trend is upward.

[0089] Normalize the differences that represent the trend:

[0090]

[0091] Get the normalized result:

[0092]

[0093] The normalized results are expressed as trend vector matrix.

[0094] In an implementation of the present application, nn.Embedding is used to perform trend vectorization matrix expression.

[0095] The overall formula is as follows:

[0096]

[0097] In an implementation manner of the present application, the clothing sales data set is divided into a training set, a validation set, and a test set in a ratio of 7:2:1 through a data processing module.

[0098] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the above embodiments do not limit the present invention in any form, and any technical solution obtained by equivalent replacement or equivalent transformation falls within the protection scope of the present invention.

Claims

1. A clothing sales prediction method based on an improved Transformer model, characterized in that: Include: Get the clothing sales data set; The clothing sales data set is divided into training set, validation set, and test set; Constructing an improved Transformer model, wherein the improved Transformer model includes a trend encoding matrix, and the trend encoding matrix is ​​used to perform trend encoding on the input sales volume features; The constructed improved Transformer model is trained through the clothing sales data set, and the clothing sales prediction results are output through the trained improved Transformer model.

2. The clothing sales prediction method based on the improved Transformer model according to claim 1 is characterized in that: The specific method of the trend coding matrix to perform trend coding on the input sales features is as follows: For a given set of sales features x = [x1, x2, x3, ...], Calculate the mean, maximum, and minimum values ​​of the sales feature: m=min(x) M=max(x) Calculate the difference between each feature point in the sales feature and the mean. Among them, if the difference is negative, it means that the trend of this point is downward, and if the difference is positive, the trend is upward; Normalize the differences that represent the trend: Get the normalized result: The normalized results are expressed as trend vector matrix.

3. The clothing sales prediction method based on the improved Transformer model according to claim 2 is characterized in that: Use nn.Embedding for trend vectorization matrix expression.

4. The clothing sales prediction method based on the improved Transformer model according to claim 1 is characterized in that: The clothing sales data set is divided into training set, validation set, and test set in a ratio of 7:2:

1.

5. The clothing sales prediction method based on the improved Transformer model according to claim 1 is characterized in that: The data in the clothing sales data set contains actual sales data for each month of previous years.

6. A clothing sales prediction system based on an improved Transformer model, characterized in that: Include: Data acquisition module, used to obtain clothing sales data set; The data processing module is used to divide the clothing sales data set into a training set, a validation set, and a test set; A model building module, used to build an improved Transformer model, wherein the improved Transformer model includes a trend coding matrix, and the trend coding matrix is ​​used to perform trend coding on input sales features; The constructed improved Transformer model is trained through the clothing sales data set, and the clothing sales prediction results are output through the trained improved Transformer model.

7. The clothing sales prediction system based on the improved Transformer model according to claim 6 is characterized in that: The specific method of the trend coding matrix to perform trend coding on the input sales features is as follows: For a given set of sales features x = [x1, x2, x3, ...], Calculate the mean, maximum, and minimum values ​​of the sales feature: m=min(x) M=max(x) Calculate the difference between each feature point in the sales feature and the mean. Among them, if the difference is negative, it means that the trend of this point is downward, and if the difference is positive, the trend is upward; Normalize the differences that represent the trend: Get the normalized result: The normalized results are expressed as trend vector matrix.

8. The clothing sales forecasting system based on the improved Transformer model according to claim 7 is characterized in that: Use nn.Embedding for trend vectorization matrix expression.

9. The clothing sales prediction method based on the improved Transformer model according to claim 6 is characterized in that: The clothing sales data set is divided into a training set, a validation set, and a test set in a ratio of 7:2:1 through the data processing module.

10. The clothing sales prediction method based on the improved Transformer model according to claim 6, characterized in that: The data in the clothing sales data set acquired by the data acquisition module includes actual sales data of each month in previous years.

Citation Information

Cited By

  • Generative large model-based event popularity prediction method and system

    CN121256748A