Training methods for quantity-price relationship models, methods for determining product sales volume, and related devices.
By calculating the sales weighting coefficient and the average sales data of the price attribute, a volume-price relationship model is trained, and Bayesian updates are performed locally. This solves the single point of failure risk and inefficiency problem of the central server, and realizes the learning of volume-price relationship in the instant retail scenario.
Patent Information
- Application Number
- CN202510593351.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2026-11-10
AI Technical Summary
The central server has a single point of failure risk in learning the relationship between quantity and price and has low parameter update efficiency. In particular, it cannot update model parameters when the network is interrupted, which affects the price adjustment suggestions of retailers.
By calculating the sales weighting coefficient and average sales data of each item over a time period, a machine learning model is trained. The parameters are then updated locally using a Bayesian update method, distributing the computational load across each store and avoiding the central server becoming a performance bottleneck.
It enables parameter updates even when the network is interrupted, reducing the risk of single point of failure, improving parameter update efficiency, and adapting to the learning of quantity-price relationships in real-time retail scenarios.
Smart Images

Figure CN123070985A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of big data processing and mining technology, and in particular to a training method for a quantity-price relationship model, a method for determining the sales volume of goods, an apparatus, an electronic device, and a computer-readable medium. Background Technology
[0002] In the field of volume-price relationship learning, existing technologies mainly focus on using machine learning algorithms for dynamic pricing and sales forecasting. These technologies can learn the impact of price changes on sales volume based on historical data, thereby providing retailers with suggestions for price adjustments. However, the following technical problems still exist: 1) If there is a temporary interruption in the network connection between the central server or the store and the central server, the store cannot update the model parameters; 2) The central server bears a large computational load, which poses a single point of failure risk, and the parameter update efficiency is low. Summary of the Invention
[0003] In view of this, embodiments of the present invention provide a training method for a quantity-price relationship model, a method for determining the sales volume of an item, and an apparatus to solve the technical problems of single point of failure risk in the central server and low parameter update efficiency.
[0004] To achieve the above objectives, according to one aspect of the present invention, a training method for a quantity-price relationship model is provided, comprising:
[0005] Calculate the sales weighting coefficient for each category in each time period based on the sales data of each item in each time period.
[0006] Based on the price attributes of each item and their corresponding effective time intervals, as well as the sales weighting coefficients of each category in each time period, calculate the average sales data corresponding to each price attribute of each item in each time period.
[0007] The machine learning model is trained using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model, thereby obtaining the quantity-price relationship model.
[0008] Optionally, based on the sales data of each item in different time periods, calculate the sales weighting coefficient for each category in different time periods, including:
[0009] Obtain sales data for each item in each time period and standardize the sales data for each item to obtain standardized sales data for each item in each time period.
[0010] For each product category, the standardized sales data of each item in that category over each time period are summed up to obtain the total sales data of that product category over each time period.
[0011] For each product category, a sales weighting coefficient is calculated based on the total sales data of that product category in each time period.
[0012] Optionally, based on the total sales data of the product category in each time period, calculate the sales weighting coefficient of the product category in each time period, including:
[0013] For each time period, the total sales data for that time period is divided by the sum of the total sales data for all time periods, and then multiplied by the total number of time periods to obtain the sales weighting coefficient for that time period.
[0014] Optionally, based on the price attributes of each item and their corresponding valid time intervals, as well as the sales weighting coefficients of each category within each time period, the average sales data corresponding to each price attribute of each item within each time period is calculated, including:
[0015] Based on the price attributes of each item and their corresponding valid time intervals, determine the time periods corresponding to each price attribute of each item.
[0016] Based on the different time periods corresponding to the different price attributes of each item, determine the sales data corresponding to the different price attributes of each item within each time period.
[0017] Based on the sales weighting coefficients of each product category in each time period and the sales data of each item's price attributes in each time period, calculate the average sales data of each item's price attributes in each time period.
[0018] Optionally, based on the sales weighting coefficients of each category in each time period and the sales data corresponding to each price attribute of each item in each time period, the average sales data corresponding to each price attribute of each item in each time period is calculated, including:
[0019] For each price attribute of each item, the sales data corresponding to that price attribute in each time period is divided by the sales weighting coefficient of the category corresponding to that item in each time period to obtain the average sales data corresponding to that price attribute of the item in each time period.
[0020] Optionally, a machine learning model is trained using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, thereby obtaining a volume-price relationship model, including:
[0021] The machine learning model is trained using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model. The parameters are then updated using a Bayesian update method to obtain the quantity-price relationship model.
[0022] Furthermore, according to another aspect of the present invention, a method for determining the sales volume of an item using a quantity-price relationship model trained by the above-described training method is provided, comprising:
[0023] Input the characteristic attributes of the target item into the sales prediction model to output the predicted sales data of the target item;
[0024] Input the characteristic attributes of the target item into the price prediction model to output the predicted price attribute of the target item;
[0025] Input the target price attribute, predicted sales volume data, and predicted price attribute of the target item into the volume-price relationship model to output the target average sales volume data of the target item.
[0026] Furthermore, according to another aspect of the present invention, a training apparatus for a quantity-price relationship model is provided, comprising:
[0027] The coefficient calculation module is used to calculate the sales weighting coefficient of each category in each time period based on the sales data of each item in each time period.
[0028] The sales calculation module is used to calculate the average sales data of each item for each price attribute in each time period based on each item's price attribute, its corresponding effective time interval, and the sales weighting coefficient of each category in each time period.
[0029] The training module is used to train a machine learning model using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, so as to obtain a quantity-price relationship model.
[0030] Furthermore, according to another aspect of the present invention, an apparatus for determining the sales volume of an item using a quantity-price relationship model trained by the above-described training method is provided, comprising:
[0031] The first sales forecasting module is used to input the characteristic attributes of the target item into the sales forecasting model in order to output the predicted sales data of the target item.
[0032] The price prediction module is used to input the characteristic attributes of the target item into the price prediction model, and output the predicted price attribute of the target item.
[0033] The second sales forecasting module is used to input the target price attribute, predicted sales data, and predicted price attribute of the target item into the volume-price relationship model to output the target average sales data of the target item.
[0034] According to another aspect of the present invention, an electronic device is also provided, comprising:
[0035] One or more processors;
[0036] Storage device for storing one or more programs.
[0037] When the one or more programs are executed by the one or more processors, the one or more processors implement the methods of any of the above embodiments.
[0038] According to another aspect of the present invention, a computer-readable medium is also provided having a computer program stored thereon that, when executed by a processor, implements the methods of any of the above embodiments.
[0039] According to another aspect of the present invention, a computer program product is also provided, including a computer program that, when executed by a processor, implements the method of any of the above embodiments.
[0040] One embodiment of the above invention has the following advantages or beneficial effects: the computational pressure is distributed to each store, avoiding the central server from becoming a performance bottleneck or a single point of failure; if the network connection between the central server or the store and the central system is temporarily interrupted, the store can continue to update parameters based on newly generated local data as long as it has the necessary model and the current parameter status; the central server can use a parallel approach to greatly improve the efficiency of parameter updates.
[0041] The further effects of the aforementioned unconventional alternative methods will be explained below in conjunction with specific implementation methods. Attached Figure Description
[0042] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0043] Figure 1 This is a flowchart of a training method for a quantity-price relationship model according to an embodiment of the present invention;
[0044] Figure 2 This is a flowchart of a training method for a quantity-price relationship model according to a possible embodiment of the present invention;
[0045] Figure 3 This is a flowchart of a method for determining the sales volume of an item according to an embodiment of the present invention;
[0046] Figure 4 This is a schematic diagram of a training device for a quantity-price relationship model according to an embodiment of the present invention;
[0047] Figure 5 This is a schematic diagram of an apparatus for determining the sales volume of an item according to an embodiment of the present invention;
[0048] Figure 6 This is an exemplary system architecture diagram in which embodiments of the present invention can be applied;
[0049] Figure 7 This is a schematic diagram of the structure of a computer system suitable for implementing terminal devices or servers of the present invention. Detailed Implementation
[0050] The following description, in conjunction with the accompanying drawings, illustrates exemplary embodiments of the present invention, including various details to aid understanding. These details should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the invention. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0051] It should be noted that the collection, gathering, updating, analysis, processing, use, transmission, and storage of user personal information involved in the technical solution of this invention all comply with the provisions of relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. Necessary measures are taken to prevent unauthorized access to user personal information data and to safeguard user personal information security, network security, and national security.
[0052] Figure 1 This is a flowchart of a training method for a quantity-price relationship model according to an embodiment of the present invention. As one embodiment of the present invention, such as... Figure 1 As shown, the training method for this quantity-price relationship model may include:
[0053] Step 101: Calculate the sales weighting coefficient of each category in each time period based on the sales data of each item in each time period.
[0054] In this step, order data for a store (which can be an online store or an offline store) can be obtained within a recent period (such as the last month, the last half month, or the last week). Then, based on the order data within the recent period, the sales data of each item in each time period can be calculated. Next, based on the sales data of each item in each time period, the total sales data of each category in each time period can be calculated. Finally, based on the total sales data of each category in each time period, the sales weighting coefficient of each category in each time period can be calculated.
[0055] Optionally, the time period can be one hour, two hours, or three hours, etc., and this embodiment of the invention does not limit this. For instant retail, where price elasticity varies across different time periods, this embodiment of the invention groups and statistically analyzes the sales volume of all items within the same category by hour, and calculates the sales weighting coefficient for each category at each hour. This allows the machine learning model to capture changes in price elasticity between different hours, thereby more accurately reflecting the price-volume relationship in instant retail scenarios.
[0056] Step 102: Calculate the average sales data of each item's price attributes in each time period based on each item's price attributes, their corresponding effective time intervals, and the sales weighting coefficients of each category in each time period.
[0057] In this step, the effective time intervals of each price attribute of each item in the store in the recent period are obtained. Then, based on the effective time intervals of each price attribute of each item and the sales weighting coefficients of each category in each time period calculated in step 101, the average sales data of each price attribute of each item in each time period are calculated.
[0058] Optionally, the time period can be one hour, two hours, or three hours, etc., and this embodiment of the invention does not impose any limitations on this. It should be noted that the granularity of the time period in step 102 is the same as the granularity of the time period in step 101. If the sales weighting coefficient of each category in each hour is calculated in step 101, then the average sales data corresponding to each price attribute of each item in each hour is also calculated in step 102. Similarly, if the sales weighting coefficient of each category in every two hours is calculated in step 101, then the average sales data corresponding to each price attribute of each item in every two hours is also calculated in step 102, which will not be elaborated further.
[0059] Step 103: Train the machine learning model using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model, so as to obtain the quantity-price relationship model.
[0060] Before step 103, the features of each item can be pre-processed, and then two models can be trained using these processed item features: a sales prediction model and a price prediction model. These two models are used to predict sales data and price attributes, respectively. The item features are shown in Table 1.
[0061] Table 1. Item characteristics and descriptions
[0062]
[0063]
[0064] Step 102 calculates the average sales data for each price attribute of each item within each time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model. These are used as training samples to train the machine learning model, thereby obtaining the volume-price relationship model. It should be noted that a training sample includes the average sales data for a specific price attribute of an item within a specific time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model. Optionally, the machine learning model can be a Poisson semi-parametric model, or other models such as linear regression, logistic regression, ridge regression, Lasso regression, decision trees, random forests, gradient boosting trees (GBDT), XGBoost, LightGBM, CatBoost, support vector machines, etc.
[0065] Preferably, for the instant retail scenario, this embodiment of the invention proposes a Poisson semi-parametric model to fit the quantity-price relationship. This model can relatively effectively achieve data sharing between the store and category dimensions in the instant retail scenario, improving the training effect of the model in this scenario. The following uses an item as an example to illustrate the quantity-price fitting scheme.
[0066] Given a sales cycle T, which contains several hours t = 1, 2, ..., T.
[0067] Given a total of n shops, let I be the set of all shops, where I = {1, 2, ..., i, ..., n}.
[0068] Assuming that the sales data of store i at time t (a certain hour) follows a Poisson distribution, then for a specific store i and a specific time period t, the following function can be obtained:
[0069] Yit |X it ,P it ~Poisson(λ) i )
[0070] Among them, X it λ represents the characteristics of an item. i P represents the mean of the Poisson distribution, which is the expected value of sales. it This represents the price attribute of store i during period t.
[0071] The parameter λ of the Poisson process conforms to the following function:
[0072] ln(λ i ) = P it θ T X it
[0073] Where θ represents the parameter to be fitted, which is related to price elasticity.
[0074] It should be noted that, due to item characteristic X it Possibly related to price attribute P it There is a correlation, for example, X it The price may be lower when the DOW is on Saturday or Sunday, and X it Compared with sales data Y it There are also correlations, such as lower sales of a certain item on Saturdays and Sundays. Therefore, this invention uses residuals for modeling. The residual model can isolate the fitting error caused by this correlation from the model, helping to accurately predict average sales data. Transforming the above equation into residual form, we obtain the following function:
[0075] ln(λ i )-ln(E[Y it |X it ])=(P it -E[P it |X it ])θ T X it
[0076] Among them, P it The table shows the price attribute Y of a certain item within a certain period t. it E[P] represents the average sales data of a certain item within a certain period t. it |X it ] represents the price attribute output by the price prediction model, E[Y it |X it ] represents the sales data output by the sales forecasting model, ln(λ) i )-ln(E[Y it |Xit ]) represents the residual in sales volume, P it -E[P it |X it [] indicates the price residual.
[0077] Optionally, step 103 may include: training a machine learning model using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, and updating the parameters using a Bayesian update method to obtain a quantity-price relationship model.
[0078] To obtain the θ parameters during training, the parameters of the quantity-price relationship model can be updated using a Bayesian update method. The specific update steps include:
[0079] Step 1. For any store i and any time t of the current item, train a model φ, where Y = φ(X), which is the sales prediction model.
[0080] Step 2. For any store i and any time t of the current item, train a model ψ, with the value P = ψ(X), which is the price prediction model.
[0081] Step 3. For a specific store i, provide an initialization parameter vector. It also provides a diagonal initial covariance matrix I, with all values being 1.
[0082] Step 4. Next, for each set of training data given i and t, update the model parameters θ using a Bayesian-based parameter update mechanism. i :
[0083] Based on the current parameter X it The fitting results for the sales volume prediction model φ and the price prediction model ψ were obtained respectively:
[0084] From iteration j to iteration j+1, perform the following update:
[0085]
[0086] In the above formula, a scalar value is calculated to represent the deviation from the price ΔP. it The associated squared “surprise” or variance, and is determined by the uncertainty of the current parameter (Σ). ij Weighted. Larger l j+1 This means that under the current model uncertainty, the observed price deviations are more unexpected.
[0087]
[0088] In the above formula, based on the current parameter estimates Observed price deviation ΔP it And the baseline logarithm requirement for model φ prediction Calculate ln(λ) i The predicted value of Y. This is the model's estimate considering actual observation requirements. it Previously, this was the best guess at the logarithmic demand rate.
[0089]
[0090] In the above formula, q j+1 This represents the inferred logarithmic demand rate after incorporating information relevant to the current observations.
[0091]
[0092] In the above equation, the estimate of the parameter vector θ is updated.
[0093] Previous estimates.
[0094] q j+1 -e j+1 Prediction error in the logarithmic demand rate space – the updated logarithmic rate q j+1 Compared with the initial predicted logarithmic rate e k+1 difference.
[0095] Based on the current uncertainty Σ j and price deviation ΔP it The direction / amplitude is used to adjust the update amount, and the variance term l is used to adjust the update amount. j+1 Normalize.
[0096]
[0097] In the above formula, v j+1 It is an intermediate term for the update magnitude of the covariance of a control parameter. A larger v j+1 The estimated Poisson rate corresponding to the current data point is relatively small. This indicates that the observation provides relatively little information to reduce the uncertainty of the price elasticity parameter θ, and therefore the reduction in the covariance matrix is also small when updating it.
[0098]
[0099] In the above formula, the term subtracted reduces the covariance (uncertainty), the magnitude of which depends on the gain term (Σ). ij ΔP it / l j+1 ), the direction of price deviation (ΔP) it ) and factor (1-vj+1 / l j+1 The latter reflects how much information current observations provide to reduce uncertainty (related to variance reduction).
[0100] By using newly observed data points, the parameter θ is continuously corrected. i The estimate.
[0101] Step 5. Output the fitted parameters θ i .
[0102] It should be noted that the parameter updates for this store rely on models φ and ψ trained based on the entire store's data, and θ updated based on the current store's sales data. i This allows for the expansion of data on a larger scale.
[0103] In embodiments of the present invention, the covariance matrix is used to quantify the uncertainty of parameters.
[0104] In the j-th step of the iteration, Σ ij This represents the current state of the parameter vector θ. ij The degree of uncertainty in the estimated values. The diagonal elements of the matrix represent the variance of each parameter estimate; the larger the variance, the more uncertain the estimate of that parameter. The off-diagonal elements of the matrix represent the covariance between different parameter estimates; the covariance indicates the degree and direction of the linear correlation between the parameters. If the current uncertainty about the parameter is large (i.e., Σ...), then... ij When the element values are larger, the model will "trust" the information from new observations more, resulting in larger gains and correspondingly larger parameter adjustments. Conversely, if Σ... ij If the value is very small (indicating confidence in the current parameter estimates), the gain will be small, the parameter adjustment range will be small, and the model will be more inclined to maintain the existing estimates.
[0105] This invention first trains two general models using historical data from all stores: one for predicting sales data (φ model) and the other for predicting price attributes (ψ model), capturing general market patterns. Then, it uses specific sales data from a single store and a Bayesian update mechanism (Step 4) to individually adjust the store's price elasticity parameter θ. i This "global learning + local adjustment" model allows the model to utilize general patterns learned from the overall data while adapting to the unique market environment and user behavior of each store, achieving effective use of information on a larger scale and localized adaptation of the model.
[0106] Compared with traditional Bayesian methods, the training method provided in this embodiment of the invention does not require the acquisition of the entire dataset. Instead, it can update parameters based on each piece of data obtained from the store in real time. Therefore, it has lower hardware requirements and is easier to deploy (the traditional method summarizes data in real time every hour, synchronizes it to a central server, and then distributes the updated data to each store, while this method can update parameters in real time locally in the store based on existing parameters and the new sales data of the current hour).
[0107] Therefore, the training method provided by the embodiments of the present invention has the following advantages:
[0108] I. Fault tolerance:
[0109] Network interruption robustness: If the network connection between the central server or the store and the central server is temporarily interrupted, the store side can still function as long as it has the necessary model (φ,ψ) and the current parameter state (θ). i ,Σ ij In this case, the system can continue to update parameters based on newly generated local data. However, a system that relies entirely on real-time updates from a central server will completely stop updating in this situation.
[0110] Reduce the risk of single point of failure: The computing load is distributed among various stores, avoiding the central server becoming a performance bottleneck or a single point of failure (for update computing).
[0111] II. Hardware Requirements:
[0112] For the store-side (local update): The computational resources required to perform a single update calculation in Step 4 (mainly vector and matrix operations) are lower than those required to run complex batch Bayesian analyses (such as MCMC) on the entire dataset on a central server.
[0113] It should be noted that even when using a centralized processing method to update the parameter θ for all stores... i However, embodiments of the present invention can still employ a parallel approach to significantly improve the efficiency of parameter updates.
[0114] The specific steps include:
[0115] Global model preparation (prerequisites):
[0116] Steps 1 and 2 have been completed, and globally shared sales forecasting model φ and price forecasting model ψ have been trained. These two models have been loaded into the central server's memory and are accessible to all parallel processes.
[0117] Parameter initialization (parallel / serial):
[0118] Initialize the parameter vectors for each store i = 1, 2, ..., n in the system. The covariance matrix Σ i0 This step can be performed in parallel, with each processor core or thread responsible for initializing a portion of the store's parameters.
[0119] Data distribution and parallel processing (core steps):
[0120] The training dataset H of all stores it =(Y it ,X it ,P it (or data batches divided by time t) are allocated to multiple parallel computing units (e.g., cores of a multi-core CPU, multi-threading, or distributed computing nodes). Step 4 is executed in parallel; specifically, each computing unit independently processes one or more store i (or data points H) assigned to it. it ) Perform the update calculation in Step 4: Obtain the current parameter state (θ) of store i. ij ,Σ ij ), obtain the corresponding training data H it =(Y it ,X it ,P it The predicted values are calculated using the global model φ and ψ. Calculate intermediate variables: l j+1 e j+1 q j+1 v j+1 ; Calculate the updated parameters and covariance matrix: θ ij+1 and Σ ij+1 .
[0121] Because of the calculation of θ for store i ij+1 and Σ ij+1 It mainly depends on its own θ ij , Σ ij And data H it In the global model, the update calculations between different stores are independent when processing the same data point or the same batch of data, and do not need to wait for the calculation results of other stores.
[0122] State updates and iterations:
[0123] After each computational unit completes its calculation, the updated θ will be... ij+1 and Σ ij+1 Write back to central storage (such as memory or a database) as input state for the next iteration.
[0124] Repeat Step 3 and Step 4 until all training data has been processed or the predetermined number of iterations has been reached.
[0125] Figure 2This is a flowchart of a training method for a quantity-price relationship model according to a possible embodiment of the present invention. As another embodiment of the present invention, such as... Figure 2 As shown, training methods for the quantity-price relationship model may include:
[0126] Step 201: Obtain the sales data of each item in each time period and standardize the sales data of each item to obtain the standardized sales data of each item in each time period.
[0127] Retrieve the historical order table, which records the sales information of the items, including the order number (sale_ord_id), the order time (sale_ord_tm), and the sales quantity (sale_qtty).
[0128] Taking a store as an example, the sales of all items in the same category are first grouped and statistically analyzed by hour, generating a basic table that records the sales of each item in different hours.
[0129] To eliminate differences in sales volume across different items and reduce the impact of outliers, sales data is standardized. The standardization formula used is: value = (value - median) / (p75 - p25) + 1, where median is the median, and p75 and p25 are the 75th and 25th quantiles, respectively. When p75 and p25 are the same, an alternative standardization scheme is used: value = (value - median) / (p95 - p5) + 1, where p95 and p5 are the 95th and 5th quantiles, respectively. If p95 and p5 are also the same, it means that sales volume has no distinguishing significance across hours, and the data for this item is not used.
[0130] The standardized sales data of each item in each time period can be obtained by following the above steps. For example, the standardized sales data of item A in each time period (with one hour as a time period) is shown in Table 2, and the standardized sales data of item B in each time period is shown in Table 3.
[0131] Table 2
[0132] Sales period Sales volume Standardized sales 08:00 20 1.00 09:00 18 0.76 10:00 25 1.59 11:00 30 2.18 12:00 28 1.94 13:00 22 1.24 14:00 20 1.00 15:00 18 0.76 16:00 15 0.41 17:00 10 -0.18 …… …… ……
[0133] Table 3
[0134]
[0135]
[0136] Step 202: For each category, sum up the standardized sales data of each item in the category over each time period to obtain the total sales data of the category over each time period.
[0137] For each product category (such as a third-level or second-level category), the standardized sales data of each item under that category in each time period are summed up to obtain the total sales data of that category in each time period.
[0138] Step 203: For each product category, calculate the sales weighting coefficient for that product category in each time period based on the total sales data of that product category in each time period.
[0139] For each product category (e.g., a third-level or second-level category) and each time period, the total sales data for that time period is divided by the sum of the total sales data for all time periods, and then multiplied by the total number of time periods to obtain the sales weighting coefficient for each time period. Taking a day as an example, it is divided into 24 time periods, and the total sales data for that time period is divided by the sum of the total sales data for all time periods, and then multiplied by 24 to obtain the sales weighting coefficient for each time period.
[0140] For example, the sales weighting coefficients for this product category in various time periods can be obtained based on the data in Tables 2 and 3, as shown in Table 4.
[0141] Table 4
[0142]
[0143]
[0144] Step 204: Determine the time period corresponding to each price attribute of each item based on each price attribute and its corresponding valid time interval.
[0145] Retrieve the historical price change table, which records the price change information of items. Each row records the start time (changetime), end time (next_changetime), and price (value) of the item, as shown in Table 5.
[0146] Table 5 Historical Price Changes
[0147] Value changetime next_changetime 17.5 2025-04-01 14:00:05 2025-04-01 16:15:12 16 2025-04-01 16:15:12 2025-04-01 20:35:22 15 2025-04-01 20:35:22 2025-04-01 23:45:17
[0148] To process the historical price change table and order table, we first need to define how to combine the start time (changetime) and end time (next_changetime) of each price with the sales weighting factor to calculate the duration and sales volume. Specifically, we define time intervals, and for each price attribute, filter out complete hours within them, marking the start and end of each hour as T. start ,T end For example, as shown in Table 6.
[0149] Table 6 shows the complete hours obtained through filtering.
[0150] Value <![CDATA[T start ]]> <![CDATA[T end ]]> 17.5 2025-04-01 15:00:00 2025-04-01 16:00:00 16 2025-04-01 17:00:00 2025-04-01 18:00:00 16 2025-04-01 18:00:00 2025-04-01 19:00:00 16 2025-04-01 19:00:00 2025-04-01 20:00:00 15 2025-04-01 21:00:00 2025-04-01 22:00:00 15 2025-04-01 22:00:00 2025-04-01 23:00:00
[0151] Step 205: Based on the time periods corresponding to the price attributes of each item, determine the sales data corresponding to each price attribute of each item within each time period.
[0152] Retrieve the historical order table, which records the sales information of the items, including the order number (sale_ord_id), the order time (sale_ord_tm), and the sales quantity (sale_qtty), as shown in Table 7.
[0153] Table 7 Historical Orders
[0154] Sale_ord_id Sale_ord_tm Sale_qtty 1 2025-04-01 15:21:00 2 2 2025-04-01 17:15:00 1 3 2025-04-01 17:34:00 3 4 2025-04-01 18:22:00 2 5 2025-04-01 19:12:00 1 6 2025-04-01 20:12:00 1 7 2025-04-01 21:12:00 1 8 2025-04-01 22:12:00 1
[0155] Next, filter from the historical order table for orders within the price validity period [T] start ,T end For orders placed within [the specified time period], based on the item details in each order and the corresponding time periods for each item's price attributes, the sales data for each item's price attributes within each time period is determined, as shown in Table 8.
[0156] Table 8 shows the sales data for each price attribute within each time period.
[0157] Value <![CDATA[T start ]]> <![CDATA[T end ]]> S 17.5 2025-04-01 15:00:00 2025-04-01 16:00:00 2 16 2025-04-01 17:00:00 2025-04-01 18:00:00 4 16 2025-04-01 18:00:00 2025-04-01 19:00:00 2 16 2025-04-01 19:00:00 2025-04-01 20:00:00 1 15 2025-04-01 21:00:00 2025-04-01 22:00:00 1 15 2025-04-01 22:00:00 2025-04-01 23:00:00 1
[0158] Optionally, to eliminate differences in price attributes among different items and reduce the impact of outliers, the price attributes can be further standardized. The standardization formula used is: value = (value - median) / (p75 - p25) + 1, where median is the median, and p75 and p25 are the 75th and 25th quantiles, respectively. When p75 and p25 are the same, an alternative standardization scheme is used: value = (value - median) / (p95 - p5) + 1, where p95 and p5 are the 95th and 5th quantiles, respectively. If p95 and p5 are also the same, it means that the price attribute has no distinguishing power in the hourly dimension, and the data for this item is not used.
[0159] Step 206: Based on the sales weighting coefficients of each category in each time period and the sales data of each item's price attributes in each time period, calculate the average sales data of each item's price attributes in each time period.
[0160] Optionally, step 206 may include: for each price attribute of each item, dividing the sales data corresponding to the price attribute in each time period by the sales weighting coefficient of the corresponding category in each time period to obtain the average sales data corresponding to the price attribute of the item in each time period. The sales data in each time period can be calculated using the following formula:
[0161] S avg =S / D
[0162] Among them, S avg S represents average sales data, D represents sales data within a certain time period, and D represents the weighted coefficient of sales for a certain product category within a certain time period.
[0163] For example, the calculation results are shown in Table 9.
[0164] Table 9 shows the average sales volume for each price attribute over different time periods.
[0165] Value <![CDATA[T start ]]> <![CDATA[T end ]]> S D <![CDATA[S avg ]]> 17.5 2025-04-01 15:00:00 2025-04-01 16:00:00 2 0.7 2.86 16 2025-04-01 17:00:00 2025-04-01 18:00:00 4 0.8 5 16 2025-04-01 18:00:00 2025-04-01 19:00:00 2 1.0 2 16 2025-04-01 19:00:00 2025-04-01 20:00:00 1 1.5 0.67 15 2025-04-01 21:00:00 2025-04-01 22:00:00 1 1.2 0.83 15 2025-04-01 22:00:00 2025-04-01 23:00:00 1 0.7 1.42
[0166] In the context of instant retail, the hourly sales fluctuations of items are quite significant. Compared with the traditional daily-based volume-price relationship model, this application can more accurately capture the sales dynamics in the instant retail scenario and improve the learning accuracy under the condition of limited data samples.
[0167] Step 207: Use the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model to train the machine learning model, thereby obtaining the quantity-price relationship model.
[0168] For instant retail, where price elasticity varies across different hours, this invention changes the traditional quantity-price relationship model, enabling it to capture changes in quantity-price elasticity across different hours, thus more accurately reflecting the quantity-price relationship in instant retail scenarios.
[0169] Figure 3 This is a flowchart of a method for determining sales volume of goods according to an embodiment of the present invention. As another embodiment of the present invention, such as... Figure 3 As shown, methods for determining item sales volume may include:
[0170] Step 301: Input the characteristic attributes of the target item into the sales prediction model to output the predicted sales data of the target item.
[0171] Step 302: Input the characteristic attributes of the target item into the price prediction model to output the predicted price attribute of the target item.
[0172] First, two general models are trained using historical data from all stores: one for predicting sales volume (φ model) and the other for predicting price attributes (ψ model), capturing general market patterns. The characteristics of the target item are then input into the sales volume prediction model and the price prediction model, respectively, outputting the predicted sales volume and predicted price attributes of the target item.
[0173] It should be noted that the execution order of steps 301 and 302 is not important. Step 301 can be executed first and then step 302, or step 302 can be executed first and then step 301, or steps 301 and 302 can be executed simultaneously. This embodiment of the invention does not impose any restrictions on this.
[0174] Step 303: Input the target price attribute, predicted sales volume data, and predicted price attribute of the target item into the volume-price relationship model to output the target average sales volume data of the target item.
[0175] The trained quantity-price relationship model is shown below:
[0176]
[0177] It is equivalent to:
[0178] λ l ′=E[Y it |X it ]exp((P it -E[P it |X it ])θ T X it )
[0179] Assume that the predicted price attribute [P] is output by the price prediction model. it |X it = 25 yuan, actual expected price attribute P it =22 yuan, the predicted sales data E[Y] output by the sales prediction model it |X it = 10 items / hour, the currently learned parameters θ and X it The result is θ T X it =-0.2, then we can calculate λ i = 18 units / hour. That is to say, if the expected price is reduced by 3 yuan, the expected sales volume based on the volume-price relationship model is 18 units / hour.
[0180] This application can more accurately capture sales dynamics in real-time retail scenarios and improve learning accuracy under conditions of limited data samples.
[0181] Figure 4 This is a schematic diagram of a training device for a quantity-price relationship model according to an embodiment of the present invention. Figure 4 As shown, the training device 400 for the volume-price relationship model includes a coefficient calculation module 401, a sales volume calculation module 402, and a training module 403. The coefficient calculation module 401 calculates the sales weighting coefficients for each category within each time period based on the sales volume data of each item within each time period. The sales volume calculation module 402 calculates the average sales volume data corresponding to each price attribute of each item within each time period based on each price attribute of each item, its corresponding effective time interval, and the sales weighting coefficients for each category within each time period. The training module 403 trains a machine learning model using the average sales volume data corresponding to each price attribute of each item within each time period, the sales volume data output by the sales volume prediction model, and the price attributes output by the price prediction model, thereby obtaining the volume-price relationship model.
[0182] Optionally, the coefficient calculation module 401 is also used for:
[0183] Obtain sales data for each item in each time period and standardize the sales data for each item to obtain standardized sales data for each item in each time period.
[0184] For each product category, the standardized sales data of each item in that category over each time period are summed up to obtain the total sales data of that product category over each time period.
[0185] For each product category, a sales weighting coefficient is calculated based on the total sales data of that product category in each time period.
[0186] Optionally, the coefficient calculation module 401 is also used for:
[0187] For each time period, the total sales data for that time period is divided by the sum of the total sales data for all time periods, and then multiplied by the total number of time periods to obtain the sales weighting coefficient for that time period.
[0188] Optionally, the sales calculation module 402 is also used for:
[0189] Based on the price attributes of each item and their corresponding valid time intervals, determine the time periods corresponding to each price attribute of each item.
[0190] Based on the different time periods corresponding to the different price attributes of each item, determine the sales data corresponding to the different price attributes of each item within each time period.
[0191] Based on the sales weighting coefficients of each product category in each time period and the sales data of each item's price attributes in each time period, calculate the average sales data of each item's price attributes in each time period.
[0192] Optionally, the sales calculation module 402 is also used for:
[0193] For each price attribute of each item, the sales data corresponding to that price attribute in each time period is divided by the sales weighting coefficient of the category corresponding to that item in each time period to obtain the average sales data corresponding to that price attribute of the item in each time period.
[0194] Optionally, the training module 403 is also used for:
[0195] The machine learning model is trained using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attribute output by the price prediction model. The parameters are then updated using a Bayesian update method to obtain the quantity-price relationship model.
[0196] Figure 5 This is a schematic diagram of an apparatus for determining the sales volume of an item according to an embodiment of the present invention. Figure 5 As shown, the device 500 for determining the sales volume of an item includes a first sales volume prediction module 501, a price prediction module 502, and a second sales volume prediction module 503. The first sales volume prediction module 501 is used to input the characteristic attributes of the target item into a sales volume prediction model to output the predicted sales volume data of the target item. The price prediction module 502 is used to input the characteristic attributes of the target item into a price prediction model to output the predicted price attribute of the target item. The second sales volume prediction module 503 is used to input the target price attribute, the predicted sales volume data, and the predicted price attribute of the target item into a quantity-price relationship model to output the target average sales volume data of the target item.
[0197] Figure 6 An exemplary system architecture 600 is shown, which can be applied to the training method of the quantity-price relationship model, the method for determining the sales volume of an item, the training device of the quantity-price relationship model, or the device for determining the sales volume of an item.
[0198] like Figure 6 As shown, system architecture 600 may include terminal devices 601, 602, and 603, a network 604, and a server 605. Network 604 serves as the medium for providing communication links between terminal devices 601, 602, and 603 and server 605. Network 604 may include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0199] Users can use terminal devices 601, 602, and 603 to interact with server 605 via network 604 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 601, 602, and 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0200] Terminal devices 601, 602, and 603 can be various electronic devices with displays and web browsing capabilities, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0201] Server 605 can be a server that provides various services, such as a backend management server that supports shopping websites browsed by users using terminal devices 601, 602, and 603 (this is just an example). The backend management server can analyze and process data such as received item information query requests, and then feed the processing results back to the terminal devices.
[0202] It should be noted that the training method of the quantity-price relationship model or the method of determining the sales volume of an item provided in the embodiments of the present invention can be executed by the server 605 or by the terminal devices 601, 602, and 603; correspondingly, the training device of the quantity-price relationship model or the device for determining the sales volume of an item can be set in the server 605 or in the terminal devices 601, 602, and 603.
[0203] It should be understood that Figure 6 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0204] The following is for reference. Figure 7 It shows a schematic diagram of the structure of a computer system 700 suitable for implementing a terminal device of the present invention. Figure 7 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0205] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 702 or programs loaded from storage section 708 into random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the system 700. The CPU 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0206] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, mouse, etc.; an output section 707 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 710 as needed so that computer programs read from it can be installed into the storage section 708 as needed.
[0207] In particular, according to the embodiments disclosed in this invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this invention include a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 709, and / or installed from removable medium 711. When the computer program is executed by central processing unit (CPU) 701, it performs the functions defined above in the system of this invention.
[0208] It should be noted that the computer-readable medium shown in this invention can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0209] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer programs according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0210] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor may be described as including a coefficient calculation module, a sales calculation module, and a training module, wherein the names of these modules do not necessarily limit the module itself.
[0211] The modules described in the embodiments of the present invention can be implemented in software or hardware. The described modules can also be housed in a processor; for example, a processor can be described as including a first sales forecasting module, a price forecasting module, and a second sales forecasting module. The names of these modules do not necessarily limit the functionality of the module itself.
[0212] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device implements the following method: calculating the sales weighting coefficient of each category in each time period based on the sales data of each item in each time period; calculating the average sales data corresponding to each price attribute of each item in each time period based on each item's price attribute and its corresponding effective time interval, and the sales weighting coefficient of each category in each time period; training a machine learning model using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, thereby obtaining a volume-price relationship model.
[0213] In another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiments; or it may exist independently and not assembled into the device. The computer-readable medium carries one or more programs, which, when executed by the device, implement the following method: inputting the characteristic attributes of a target item into a sales prediction model to output predicted sales data of the target item; inputting the characteristic attributes of the target item into a price prediction model to output predicted price attributes of the target item; and inputting the target price attribute, predicted sales data, and predicted price attribute of the target item into a quantity-price relationship model to output target average sales data of the target item.
[0214] In another aspect, embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the method of any of the above embodiments.
[0215] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A training method for a quantity-price relationship model, characterized in that, include: Calculate the sales weighting coefficient for each category in each time period based on the sales data of each item in each time period. Based on the price attributes of each item and their corresponding effective time intervals, as well as the sales weighting coefficients of each category within each time period, calculate the average sales data corresponding to each price attribute of each item within each time period. The machine learning model is trained using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, thereby obtaining the quantity-price relationship model.
2. The method according to claim 1, characterized in that, Based on the sales data of each item in different time periods, calculate the sales weighting coefficient for each category in those time periods, including: Acquire sales data for each item in each time period and standardize the sales data for each item to obtain standardized sales data for each item in each time period. For each product category, the standardized sales data of each item in the product category during each time period are summed to obtain the total sales data of the product category during each time period. For each product category, a sales weighting coefficient for that product category in each time period is calculated based on the total sales data of that product category in each time period.
3. The method according to claim 2, characterized in that, Based on the total sales data of the product category in each time period, calculate the sales weighting coefficient of the product category in each time period, including: For each time period, the total sales data for that time period is divided by the sum of the total sales data for all time periods, and then multiplied by the total number of time periods to obtain the sales weighting coefficient for that time period.
4. The method according to claim 1, characterized in that, Based on the price attributes of each item and their corresponding valid time intervals, as well as the sales weighting coefficients of each category within each time period, the average sales data corresponding to each price attribute of each item within each time period is calculated, including: Based on the price attributes of each item and their corresponding valid time intervals, determine the time periods corresponding to each price attribute of each item. Based on the time periods corresponding to the price attributes of each item, determine the sales data corresponding to each price attribute of each item within the respective time periods. Based on the sales weighting coefficients of each product category in each time period and the sales data corresponding to each price attribute of each item in each time period, calculate the average sales data corresponding to each price attribute of each item in each time period.
5. The method according to claim 4, characterized in that, Based on the sales weighting coefficients of each product category in each time period and the sales data corresponding to each price attribute of each item in each time period, the average sales data corresponding to each price attribute of each item in each time period is calculated, including: For each price attribute of each item, the sales data corresponding to the price attribute in each time period are divided by the sales weighting coefficient of the category corresponding to the item in each time period to obtain the average sales data corresponding to the price attribute of the item in each time period.
6. The method according to claim 1, characterized in that, A machine learning model is trained using the average sales data corresponding to each price attribute of each item within each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, thereby obtaining a volume-price relationship model, including: The machine learning model is trained using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model. The parameters are then updated using a Bayesian update method to obtain the quantity-price relationship model.
7. A method for determining the sales volume of an item using a quantity-price relationship model trained according to any one of claims 1-6, characterized in that, include: Input the characteristic attributes of the target item into the sales prediction model to output the predicted sales data of the target item; The characteristic attributes of the target item are input into the price prediction model to output the predicted price attribute of the target item; The target price attribute, predicted sales volume data, and predicted price attribute of the target item are input into the volume-price relationship model to output the target average sales volume data of the target item.
8. A training device for a quantity-price relationship model, characterized in that, include: The coefficient calculation module is used to calculate the sales weighting coefficient of each category in each time period based on the sales data of each item in each time period. The sales calculation module is used to calculate the average sales data corresponding to each price attribute of each item in each time period based on each price attribute of each item and its corresponding effective time interval, as well as the sales weighting coefficient of each category in each time period. The training module is used to train a machine learning model using the average sales data corresponding to each price attribute of each item in each time period, the sales data output by the sales prediction model, and the price attributes output by the price prediction model, so as to obtain a quantity-price relationship model.
9. An apparatus for determining the sales volume of an item using a quantity-price relationship model trained by the training method described in any one of claims 1-6, characterized in that, include: The first sales forecasting module is used to input the characteristic attributes of the target item into the sales forecasting model, so as to output the predicted sales data of the target item. The price prediction module is used to input the characteristic attributes of the target item into the price prediction model, and output the predicted price attribute of the target item. The second sales forecasting module is used to input the target price attribute, predicted sales data, and predicted price attribute of the target item into the volume-price relationship model to output the target average sales data of the target item.
10. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-7.
11. A computer-readable medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-7.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.
