Method and device for calculating delivery time, electronic device and storage medium
By generating sparse and dense feature matrices and combining multiple algorithm layers, the problem of inaccurate food delivery time prediction was solved, achieving higher accuracy and global prediction results.
Patent Information
- Application Number
- CN201910696306.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-07-30
- Publication Date
- 2025-01-07
- Estimated Expiration
- 2039-07-30
AI Technical Summary
In existing technologies, the prediction of food delivery time is not accurate enough, especially the processing of sparse feature data is insufficient, which makes it difficult for the model to be balanced across the national business scope. In addition, the time compensation part is separate from the model of the initial prediction results, making it difficult to optimize together.
A feature matrix is generated using sparse and dense feature data. The FM algorithm layer, MLP algorithm layer, time-series output layer, and feature fusion layer are combined. Through feature expansion and matrix transformation, a fusion matrix is generated. The final prediction result is calculated using a conventional prediction layer and a time-interpolation layer. Different loss functions are set for model training.
It improves the accuracy and globality of order delivery time prediction, effectively handles sparse features including ID type and dense features of temporal sequence, and optimizes the overall performance of the model.
Smart Images

Figure CN112307427B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular, to a method and device for calculating delivery time, an electronic device and a storage medium. Background Art
[0002] As living standards improve, more and more users choose to order takeout. After placing an order for takeout, the takeout platform will present the user with the estimated delivery time of the order. Since the quality of the takeout meal and the user's ordering experience are directly related to the delivery time of the takeout, and the estimated delivery time is an important reference factor for users to decide when to place an order, the takeout platform attaches great importance to improving the accuracy of the estimated delivery time.
[0003] In related technologies, the delivery time prediction model is trained through some sample information related to order delivery. The sample information includes some dense feature information related to the order. The attribute value corresponding to each dense feature itself can reflect the actual situation of the order to a certain extent, such as order time, price, distance, load, etc. Summary of the invention
[0004] The purpose of the present disclosure is to provide a method and device for calculating delivery time, an electronic device and a storage medium, so as to solve the problem of inaccurate delivery time prediction in related technologies.
[0005] In order to achieve the above-mentioned purpose, in a first aspect, the present disclosure provides a method for calculating delivery time, the method comprising: obtaining pre-specified feature data related to order delivery, the feature data comprising sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to a target order, and the dense feature data comprises delivery environment indicators and quantifiable information related to the target order; generating a first feature matrix according to the sparse feature data and the dense feature data; generating a second feature matrix according to the historical dense feature data; inputting the first feature matrix and the second feature matrix into a delivery time prediction model to obtain a prediction result for the delivery time of the target order.
[0006] Optionally, the delivery time prediction model includes an FM algorithm layer, an MLP algorithm layer, a time series output layer, and a feature fusion layer; the FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix; the MLP algorithm layer is used to perform matrix transformation processing on the first feature matrix; the time series output layer is used to perform matrix transformation processing on the second feature matrix; the feature fusion layer is used to fuse the elements in the matrix output by the FM algorithm layer, the matrix output by the MLP algorithm layer, and the matrix output by the time series output layer to obtain a fusion matrix; the prediction result is calculated based on the fusion matrix.
[0007] Optionally, the delivery time prediction model also includes a regular prediction layer and a compensatory time layer; the prediction result is calculated based on the following steps: the regular time is calculated based on the fusion matrix and the operation matrix of the regular prediction layer; the operation matrix of the compensatory time layer is determined based on the characteristic data corresponding to the target order; the target compensatory time duration is calculated based on the fusion matrix and the operation matrix of the compensatory time layer; the prediction result is generated based on the regular time duration and the target compensatory time duration.
[0008] Optionally, the operation matrix of the compensation time layer determined according to the characteristic data corresponding to the target order includes: determining the attribute value corresponding to the compensation time layer according to the characteristic data; determining the data interval where the attribute value is located among multiple preset data intervals; calculating the operation matrix of the compensation time layer according to the difference between the attribute value and two end values of the data interval, and the compensation time embedding vectors corresponding to the two end values respectively found in the compensation time embedding vector library, wherein the compensation time embedding vector library includes the compensation time embedding vectors corresponding to the preset data interval end values.
[0009] Optionally, the compensatory time layer includes one or more of the following compensatory time modules: a load compensatory time module, a distance compensatory time module, a price compensatory time module, and a meal delivery difficulty compensatory time module; determining the operation matrix of the compensatory time layer according to the characteristic data corresponding to the target order, and calculating the target compensatory time duration according to the fusion matrix and the operation matrix of the compensatory time layer, including: determining the operation matrix of each compensatory time module according to the characteristic data corresponding to the target order; calculating the corresponding module compensatory time duration according to the fusion matrix and the operation matrix of each compensatory time module; generating the target compensatory time duration based on the calculated module compensatory time duration.
[0010] Optionally, the delivery time prediction model is trained in the following manner: a first loss function is set for the supplementary time layer, and a second loss function is set for the regular prediction layer, the function types of the first loss function and the second loss function are different; the feature data related to order delivery in the sample data is input into the delivery time prediction model to be trained to obtain the prediction result to be tested for the delivery time; the following operation steps of adjusting element values are repeated: the element value in the operation matrix of the supplementary time layer is adjusted according to the actual delivery time in the sample data, the prediction result to be tested, and the first loss function; the element value in the operation matrix of the regular prediction layer is adjusted according to the actual delivery time in the sample data, the prediction result to be tested, and the second loss function; until the difference between the output of the first loss function before the element value adjustment operation and the output of the first loss function after the element value adjustment operation is less than the first preset threshold, and the difference between the output of the second loss function before the element value adjustment operation and the output of the second loss function after the element value adjustment operation is less than the second preset threshold, it is determined that the training of the delivery time prediction model is completed.
[0011] Optionally, the sparse feature data includes a sparse index value and a sparse attribute value corresponding to each sparse feature, wherein the sparse attribute value is a preset value corresponding to the sparse feature; the dense feature data includes a dense index value and a dense attribute value corresponding to each dense feature, wherein the dense attribute value is a quantized value corresponding to the dense feature; generating a first feature matrix according to the sparse feature data and the dense feature data includes: performing the following operations on each sparse feature: querying a preset embedding vector library to obtain a sparse index value corresponding to the sparse feature; A sparse feature embedding vector is obtained by searching a preset embedding vector library according to the dense index value corresponding to the dense feature, and a dense feature vector corresponding to the dense feature is generated according to the dense attribute value and the dense feature embedding vector; the first feature matrix is generated based on the sparse index value and the dense index value, and the generated sparse feature vector and the dense feature vector.
[0012] Optionally, the FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix, including: taking a combination of any two of the features as a new feature, and performing the following operations on the new feature: taking the dot product of the corresponding feature vectors of the two features as the attribute value of the new feature; generating a feature vector corresponding to the new feature based on the corresponding feature vectors of the two features and the attribute value; the matrix output by the FM algorithm layer includes the feature vector corresponding to the new feature.
[0013] In a second aspect, the present disclosure provides a device for calculating delivery time, the device comprising: an acquisition module, used to acquire pre-specified feature data related to order delivery, the feature data comprising sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to a target order, and the dense feature data comprises delivery environment indicators and quantifiable information related to the target order; a first data processing module, used to generate a first feature matrix based on the sparse feature data and the dense feature data; a second data processing module, used to generate a second feature matrix based on the historical dense feature data; and a third data processing module, used to input the first feature matrix and the second feature matrix into a delivery time prediction model to obtain a prediction result for the delivery time of the target order.
[0014] Optionally, the delivery time prediction model includes an FM algorithm layer, an MLP algorithm layer, a time series output layer, and a feature fusion layer; the FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix; the MLP algorithm layer is used to perform matrix transformation processing on the first feature matrix; the time series output layer is used to perform matrix transformation processing on the second feature matrix; the feature fusion layer is used to fuse the elements in the matrix output by the FM algorithm layer, the matrix output by the MLP algorithm layer, and the matrix output by the time series output layer to obtain a fusion matrix; the prediction result is calculated based on the fusion matrix.
[0015] Optionally, the delivery time prediction model also includes a regular prediction layer and a compensatory time layer; the prediction result is calculated based on the following steps: the regular time is calculated based on the fusion matrix and the operation matrix of the regular prediction layer; the operation matrix of the compensatory time layer is determined based on the characteristic data corresponding to the target order; the target compensatory time duration is calculated based on the fusion matrix and the operation matrix of the compensatory time layer; the prediction result is generated based on the regular time duration and the target compensatory time duration.
[0016] Optionally, the operation matrix of the compensation time layer determined according to the characteristic data corresponding to the target order includes: determining the attribute value corresponding to the compensation time layer according to the characteristic data; determining the data interval where the attribute value is located among multiple preset data intervals; calculating the operation matrix of the compensation time layer according to the difference between the attribute value and two end values of the data interval, and the compensation time embedding vectors corresponding to the two end values respectively found in the compensation time embedding vector library, wherein the compensation time embedding vector library includes the compensation time embedding vectors corresponding to the preset data interval end values.
[0017] Optionally, the compensatory time layer includes one or more of the following compensatory time modules: a load compensatory time module, a distance compensatory time module, a price compensatory time module, and a meal delivery difficulty compensatory time module; determining the operation matrix of the compensatory time layer according to the characteristic data corresponding to the target order, and calculating the target compensatory time duration according to the fusion matrix and the operation matrix of the compensatory time layer, including: determining the operation matrix of each compensatory time module according to the characteristic data corresponding to the target order; calculating the corresponding module compensatory time duration according to the fusion matrix and the operation matrix of each compensatory time module; generating the target compensatory time duration based on the calculated module compensatory time duration.
[0018] Optionally, the delivery time prediction model is trained in the following manner: a first loss function is set for the supplementary time layer, and a second loss function is set for the regular prediction layer, the function types of the first loss function and the second loss function are different; the feature data related to order delivery in the sample data is input into the delivery time prediction model to be trained to obtain the prediction result to be tested for the delivery time; the following operation steps of adjusting element values are repeated: the element value in the operation matrix of the supplementary time layer is adjusted according to the actual delivery time in the sample data, the prediction result to be tested, and the first loss function; the element value in the operation matrix of the regular prediction layer is adjusted according to the actual delivery time in the sample data, the prediction result to be tested, and the second loss function; until the difference between the output of the first loss function before the element value adjustment operation and the output of the first loss function after the element value adjustment operation is less than the first preset threshold, and the difference between the output of the second loss function before the element value adjustment operation and the output of the second loss function after the element value adjustment operation is less than the second preset threshold, it is determined that the training of the delivery time prediction model is completed.
[0019] Optionally, the sparse feature data includes a sparse index value and a sparse attribute value corresponding to each sparse feature, wherein the sparse attribute value is a preset value corresponding to the sparse feature; the dense feature data includes a dense index value and a dense attribute value corresponding to each dense feature, wherein the dense attribute value is a quantized value corresponding to the dense feature; a first data processing module is used to: perform the following operations on each sparse feature: query a preset embedding vector library according to the sparse index value corresponding to the sparse feature to obtain a sparse feature embedding vector, and According to the sparse attribute value and the sparse feature embedding vector, a sparse feature vector corresponding to the sparse feature is generated; for each dense feature, the following operations are performed: according to the dense index value corresponding to the dense feature, a dense feature embedding vector is queried in a preset embedding vector library to obtain a dense feature embedding vector, and according to the dense attribute value and the dense feature embedding vector, a dense feature vector corresponding to the dense feature is generated; based on the sparse index value and the dense index value, and the generated sparse feature vector and the dense feature vector, the first feature matrix is generated.
[0020] Optionally, the FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix, including: taking a combination of any two of the features as a new feature, and performing the following operations on the new feature: taking the dot product of the corresponding feature vectors of the two features as the attribute value of the new feature; generating a feature vector corresponding to the new feature based on the corresponding feature vectors of the two features and the attribute value; the matrix output by the FM algorithm layer includes the feature vector corresponding to the new feature.
[0021] In a third aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any one of the methods for calculating delivery time.
[0022] In a fourth aspect, the present disclosure provides an electronic device, comprising: a memory on which a computer program is stored; and a processor for executing the computer program in the memory to implement the steps of any one of the methods for calculating delivery time.
[0023] The above scheme can at least achieve the following technical effects:
[0024] By generating a first feature matrix based on the sparse feature data and the dense feature data related to order delivery, and generating a second feature matrix based on the historical dense feature data, the processed feature matrix is brought into the delivery time prediction model to obtain the prediction result of the delivery time of the target order. In this solution, in addition to being able to input sparse features including ID classes, historical dense features with time series can also be input for prediction, which improves the accuracy and globality of order delivery time prediction.
[0025] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0027] Figure 1 It is a structural diagram of a delivery time prediction model in the related technology.
[0028] Figure 2 The figure is a flow chart of a method for calculating delivery time shown in an exemplary embodiment of the present disclosure.
[0029] Figure 3 It is a structural diagram of a delivery time prediction model shown in an exemplary embodiment of the present disclosure.
[0030] Figure 4 It is a structural diagram of another delivery time prediction model shown in an exemplary embodiment of the present disclosure.
[0031] Figure 5 The figure is a flow chart of a method for calculating delivery time shown in an exemplary embodiment of the present disclosure.
[0032] Figure 6 The present invention is a block diagram of a device for calculating delivery time shown in an exemplary embodiment of the present invention.
[0033] Figure 7 It is a block diagram of an electronic device according to an exemplary embodiment.
[0034] Figure 8 is a block diagram of another electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0035] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0036] like Figure 1 The figure shows a schematic diagram of the structure of a delivery time prediction model in the related art. First, sample information is input into the model, which includes dense feature information of the order, such as order time, price, distance, load, etc. The sample information is calculated by two models respectively, and the results are weighted to obtain the preliminary prediction result.
[0037] In the first calculation (as shown in the dotted box in the figure), the above sample information is input into the pre-trained xgb (Xgboost) algorithm model to obtain the first output Output (xgb). The xgb algorithm model is trained based on the dense feature information in the historical order data and the actual arrival time of the order.
[0038] In the second path of calculation (as shown in the dotted box), it is first necessary to determine which model to use to perform the calculation based on the preset mode selection rule. Among them, multiple preset models can be stored in pmml format. First, based on the merchant portrait corresponding to the order, it is determined whether the order is a slow order for food delivery. If it is determined to belong to the slow order category, for example, the food preparation time is greater than 30 minutes and belongs to the slow order category, then the instruction (poislowpmml) for indicating the selection of the slow food category model is output. If it does not belong to the slow order category, it is further determined based on the user portrait corresponding to the order whether the order belongs to the difficult delivery category, for example, whether the transportation in the community where the delivery address is located is convenient, etc. If it is determined to belong to the difficult delivery order category, then the instruction (sugslowpmml) for indicating the selection of the difficult delivery category model is output. If it does not belong to the difficult delivery order category, then the instruction (normalpmml) for indicating the selection of the normal model is output. Correspondingly, the model is selected according to the instruction output according to the above rules, and the second output quantity Output (gbdt) is obtained based on the sample information and the selected model.
[0039] Further, the first output (xgb) and the second output (bgdt) are weighted averaged to obtain a preliminary prediction result. As shown in the formula in the figure, the weighting can be that each of the two outputs is assigned a weight of 0.5.
[0040] Then, the additional time is added to the preliminary prediction result to obtain the final estimated delivery time. In the related art, there are four main aspects of additional time, namely: price additional time, distance additional time, load additional time, and meal delivery additional time.
[0041] The above-mentioned model architecture of the prior art involves the following problems:
[0042] First, this model architecture processes dense order-related features. However, sparse order-related features such as ID features (user ID, category ID, POI ID, store ID), time period features (week, quarter) or weather features are often still at the level of manual rule setting, and the workload of manual optimization in the later stage is also large.
[0043] Some of the models use rules that are manually formulated, so the level of adjustment is low, making it difficult to achieve a balance across the national business scope.
[0044] The values corresponding to these sparse features in these orders are often just a string of serial numbers, such as ID data. If sparse features need to be added as expanded dimensions and substituted into the above-mentioned prior art model, such coefficient feature values cannot be classified into the valid data range, which affects the confidence of the model.
[0045] In addition, in the model architecture of the prior art, the model for the time-compensation part is separated from the model involved in the preliminary prediction results. This means that it is difficult to optimize the two models together, and the subsequent model optimization involves a large amount of data processing.
[0046] Figure 2 is a flow chart of a method for calculating delivery time shown in an exemplary embodiment of the present disclosure, and the method may include one or more of the following steps:
[0047] S21, obtaining pre-specified feature data related to order delivery, the feature data including sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to the target order, and the dense feature data includes delivery environment indicators and quantifiable information related to the target order.
[0048] The acquired feature data may be in the form of a data matrix. The feature data may use the libsvm format, in which the data is a data pair in the form of "index value: attribute value (index:value)". Each data pair corresponds to a feature.
[0049] The sparse feature data includes a sparse index value and a sparse attribute value corresponding to each sparse feature, wherein the sparse attribute value is a preset value corresponding to the sparse feature; the dense feature data includes a dense index value and a dense attribute value corresponding to each dense feature, wherein the dense attribute value is a quantized value corresponding to the dense feature.
[0050] For example, for sparse feature data, such as ID data: region ID, city ID, category ID, etc., as well as order delivery time period features (week, quarter) or weather features, etc.
[0051] The index value index in the above data pair represents the order of each feature in the data matrix, and the value of index can be increased by 1 sequentially as the order increases.
[0052] It is worth noting that the ID sequences in these sparse feature data, which represent weather sequences or time period sequences, are actual values related to orders and have no quantifiable physical meanings. The attribute value can be assigned a preset value of 1.
[0053] For example, the data pairs corresponding to the sparse feature data in the data matrix are expressed as follows:
[0054] 【1:1, 3:1, 5:1】
[0055] Among them, "1:1" means that the sequence position index is 1 and the value of the sparse feature is 1; "3:1" means that the sequence position index is 3 and the value of the sparse feature is 1; "5:1" means that the sequence position index is 5 and the value of the sparse feature is 1.
[0056] Dense feature data can include: order time, price, distance, real-time load (delivery team load), etc., and can also include historical statistical values corresponding to these dense features. For dense feature data, index represents the order of each feature in the matrix. The value of index can be increased by 1 as the order increases, and value is the attribute value of the dense feature itself.
[0057] Some of the dense class feature data pairs in the data matrix are expressed as follows:
[0058] 【10:0.7, 11:0.7】
[0059] Among them, "10:0.7" means that the sequence position index is 10 and the value of the dense feature is 0.7; "11:0.7" means that the sequence position index is 11 and the value of the sparse feature is 0.7.
[0060] S22: Generate a first feature matrix according to the sparse feature data and the dense feature data.
[0061] Specifically, the following operations are performed for each sparse feature: a sparse feature embedding vector is obtained by querying in a preset embedding vector library according to the sparse index value corresponding to the sparse feature, and a sparse feature vector corresponding to the sparse feature is generated according to the sparse attribute value and the sparse feature embedding vector.
[0062] Similarly, the following operations are performed for each dense feature: a dense feature embedding vector is obtained by querying in a preset embedding vector library according to the dense index value corresponding to the dense feature, and a dense feature vector corresponding to the dense feature is generated according to the dense attribute value and the dense feature embedding vector.
[0063] It is worth noting that the embedding vector library (dense embedding) includes a plurality of corresponding relationships between different index values and embedding vectors. Table 1 shows a corresponding relationship included in the embedding vector library:
[0064] Table 1
[0065] Index value embedding vector 1 [0.1,0.1,0.1] 2 [0.1,0.1,0.2] …… …… 5 [0.1,0.4,0.7] 6 [0.1,0.8,0.8] …… ……
[0066] Specifically, according to the index value corresponding to each feature, the embedding vector corresponding to the index value is searched in the embedding vector library. Then the found embedding vector is multiplied by the value corresponding to the feature to obtain the index vector corresponding to the feature.
[0067] For example, the fifth feature is a sparse feature. In the corresponding data pair [5:1], the sparse index value is 5, the sparse attribute value is 1, and the sparse feature embedding vector obtained by searching the sparse index value in the above embedding vector library is [0.1, 0.4, 0.7]. Further, the sparse attribute value 1 is multiplied by the obtained sparse feature embedding vector to obtain the sparse feature vector V5 = [0.1, 0.4, 0.7] corresponding to the fifth feature.
[0068] For another example, the sixth feature is the order price, whose actual value can be quantified, and the order price is a dense feature. If the order price is 20 yuan, then the data pair (index:value) of the sixth feature can be [6:20], the dense index index value is 5, and the dense attribute value is 20. The dense feature embedding vector obtained by searching the above embedding vector library with the dense index index value "6" is [0.1, 0.8, 0.8]. Further, the dense attribute value 20 is multiplied by the obtained dense feature embedding vector to obtain the dense feature vector V6 = [2, 16, 16] corresponding to the sixth feature.
[0069] Furthermore, the first feature matrix is generated based on the sparse index value and the dense index value, and the generated sparse feature vector and the dense feature vector.
[0070] The generated first feature matrix can be a matrix of feat_size*embed_size, where feat_size represents the number of features and embed_size represents the vector length of the sparse / dense feature vector corresponding to each feature. Multiple sparse / dense feature vectors can be arranged according to the above index value.
[0071] Assuming that the multiple sparse / dense feature vectors obtained are V1, V2, V3...Vn, the generated first feature matrix can be [V1; V2; V3; ...; Vn].
[0072] S23, generating a second feature matrix according to the historical dense feature data.
[0073] Dense feature data may include the number of riders, order quantity, load, etc. For example: the number of riders 10 minutes ago, the order quantity 10 minutes ago, the load 10 minutes ago, the number of riders 20 minutes ago, the order quantity 20 minutes ago, the load 20 minutes ago, the number of riders 30 minutes ago, the order quantity 30 minutes ago, the load 30 minutes ago.
[0074] The dense feature data of the history is timestamped and can be represented as a vector of [timestep, feature size], where the size part is the feature of each timestep. These dense feature data can be processed by the LSTMUnit layer, and the generated second feature matrix can be:
[0075] [Number of riders 10 minutes ago; Number of orders 10 minutes ago; Load 10 minutes ago; Number of riders 20 minutes ago; Number of orders 20 minutes ago; Load 20 minutes ago; Number of riders 30 minutes ago; Number of orders 30 minutes ago; Load 30 minutes ago]
[0076] S24, inputting the first feature matrix and the second feature matrix into a delivery time prediction model to obtain a prediction result of the delivery time of the target order.
[0077] Figure 3 As shown, a schematic diagram of the architecture of a delivery time prediction model is provided. The model may include: a feature expansion unit and a time series processing unit, as well as an FM algorithm layer, an MLP algorithm layer, a time series output layer, and a feature fusion layer.
[0078] The feature expansion unit may execute the above step S22 to generate the first feature matrix. The time sequence processing unit may execute the above step S23 to generate the second feature matrix.
[0079] Further, the first feature matrix is input into the FM algorithm layer and the MLP algorithm layer. The second feature matrix is input into the time series output layer. The function of each algorithm layer is specifically described as follows.
[0080] The FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix, including: taking a combination of any two of the features as a new feature, and performing the following operations on the new feature: taking the dot product of the corresponding feature vectors of the two features as the attribute value of the new feature; generating a feature vector corresponding to the new feature based on the corresponding feature vectors of the two features and the attribute value; the matrix output by the FM algorithm layer includes the feature vector corresponding to the new feature.
[0081] Specifically, the FM algorithm layer performs low-vector decomposition on the first feature matrix of feat_size*embed_size. Taking any two sparse / dense feature vectors Vi and Vj as an example, the attribute value of the new feature obtained by combining the two features is the dot product of the vectors Vi and Vj.
[0082] The MLP algorithm layer is used to perform matrix transformation processing on the first feature matrix. In an optional embodiment, the MLP algorithm layer flattens the first feature matrix vector of feat_size*embed_size to become a one-dimensional vector. The obtained one-dimensional vector is multiplied by a preset transformation matrix to obtain an output vector of the MLP algorithm layer. It is worth noting that the above-mentioned matrix transformation can rearrange the elements in the matrix, and can also adjust the weight of each element for subsequent calculation processing.
[0083] The time series output layer is used to perform matrix transformation processing on the second feature matrix. In specific implementation, the above second feature matrix can be processed by LSTM Unit to the form of a one-dimensional vector and expressed as: [lstm_size] = [number of riders 10 minutes ago, number of orders 10 minutes ago, load 10 minutes ago, number of riders 20 minutes ago, number of orders 20 minutes ago, load 20 minutes ago, number of riders 30 minutes ago, number of orders 30 minutes ago, load 30 minutes ago]. The above LSTM Unit will output the [lstm_size] vector periodically. When calculating, you only need to obtain the [lstm_size] vector output by the LSTM unit closest to the current moment, that is, the [lstm_size] vector output by the last time point timestep.
[0084] Furthermore, the obtained [lstm_size] vector is multiplied by the preset transformation matrix to obtain the matrix output by the temporal output layer. Multiplication by the preset transformation matrix is mainly to give different weights to the elements in the matrix and / or to rearrange the matrix elements, thereby facilitating subsequent feature fusion.
[0085] The feature fusion layer is used to fuse the elements in the matrix output by the FM algorithm layer, the matrix output by the MLP algorithm layer and the matrix output by the time series output layer to obtain a fusion matrix; the prediction result is calculated based on the fusion matrix.
[0086] For example, the output matrix of the FM algorithm layer is [0.1, 0.5], the output matrix of the MLP algorithm layer is [0.5, 1.2, 3.4], and the output matrix of the timing output layer is [0.1, 1.5]. If the above output matrices are all one-dimensional vectors, you can use the concat function to connect two or more vectors to perform matrix fusion. The synthesized fusion matrix (concat function output vector) is [0.1, 0.5, 0.5, 1.2, 3.4, 0.1, 1.5]. This method does not change the existing array, but only returns a copy of the connected array.
[0087] The above scheme can at least achieve the following technical effects:
[0088] By generating a first feature matrix based on the sparse feature data and the dense feature data related to order delivery, and generating a second feature matrix based on the historical dense feature data, the processed feature matrix is brought into the delivery time prediction model to obtain the prediction result of the delivery time of the target order. In this solution, in addition to being able to input sparse features including ID classes, historical dense features with time series can also be input for prediction, which improves the accuracy and globality of order delivery time prediction.
[0089] In specific implementation, one or more of the above-mentioned information processing units or algorithm layers can be selectively combined according to the actual business scenario to obtain the final model. For example, if the feature data to be processed itself has a time series attribute, the above-mentioned time series processing unit can be omitted in the model construction. For another example, if a cross-combination feature expansion cannot meet the business scenario requirements well, the diversity of feature expansion can be improved by constructing multiple FM algorithm layers. The above embodiment is only an architectural schematic of a preferred delivery time prediction model proposed in the present disclosure. All other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0090] Figure 4 FIG. 1 is a schematic diagram of another delivery time prediction model shown in an exemplary embodiment of the present disclosure. Figure 3 Based on the model shown, Figure 4As shown, the delivery time prediction model also includes a conventional prediction layer and a time compensation layer. After the feature fusion layer generates a fusion matrix, the fusion matrix is input into the conventional prediction layer and the time compensation layer. The conventional prediction layer is used to calculate the conventional duration according to the fusion matrix. The time compensation layer is used to calculate the target time compensation duration according to the fusion matrix.
[0091] like Figure 5 As shown, after the feature fusion layer generates the fusion matrix, the prediction result is calculated based on one or more of the following steps:
[0092] S51, obtaining a normal duration by calculating the fusion matrix and the operation matrix of the normal prediction layer.
[0093] S52, determining the operation matrix of the time compensation layer according to the characteristic data corresponding to the target order.
[0094] Specifically, the operation matrix of the compensation time layer determined according to the characteristic data corresponding to the target order includes: determining the attribute value corresponding to the compensation time layer according to the characteristic data; determining the data interval where the attribute value is located among multiple preset data intervals; calculating the operation matrix of the compensation time layer according to the difference between the attribute value and two end values of the data interval, and the compensation time embedding vectors corresponding to the two end values respectively found in the compensation time embedding vector library, wherein the compensation time embedding vector library includes the compensation time embedding vectors corresponding to the preset data interval end values.
[0095] That is to say, the operation matrix of the compensation time layer is calculated based on the preset data interval where the attribute value of the corresponding compensation time layer is located, and the compensation time embedding vector corresponding to the end value of the data interval.
[0096] The complementary embedding vector corresponding to each end value can be preset or adjusted during the model training process according to the reverse conduction rule. Each element in the complementary embedding matrix represents the sensitivity of each element in the fusion matrix (concat layer output vector).
[0097] For example, suppose the attribute value of the corresponding time-increase layer is the order price, and there are multiple price segmentation points preset for the price, such as 10 yuan, 20 yuan, 30 yuan, and 40 yuan. The values between two adjacent price segmentation points belong to a data interval, and each price segmentation point corresponds to a time-increase embedding vector. In other words, the price of 30 yuan corresponds to one time-increase embedding vector, and the price of 40 yuan corresponds to another time-increase embedding vector.
[0098] Furthermore, according to the order price of the target order and the difference (distance) between the two end values of the data interval in which it is located, the calculation weights of the time compensation embedding vectors corresponding to the two end values are determined. If the order price of the corresponding target order is 35 yuan, it is in the data interval of [30, 40]. Then the weights are 0.5 and 0.5. The operation matrix of the time compensation layer finally obtained can be expressed as: 0.5*time compensation embedding vector corresponding to end value 30 + 0.5*time compensation embedding vector corresponding to end value 40.
[0099] S53, calculating a target compensation time length according to the fusion matrix and the operation matrix of the compensation time layer.
[0100] Specifically, the product of the obtained fusion matrix and the operation matrix of the compensation time layer can be used as the target compensation time length. According to the above example, the fusion matrix (concat function output vector) is [0.1, 0.5, 0.5, 1.2, 3.4, 0.1, 1.5], which is a 1*7 matrix. The obtained operation matrix of the compensation time layer is a 7*1 matrix [0.1, 0.1, 0.2, 0.4, 0.5, 0.6, 0.7]. The product of the two matrices can be used as the target compensation time length.
[0101] like Figure 4 As shown, in an optional embodiment, the time compensation layer includes one or more of the following time compensation modules: load time compensation module, distance time compensation module, price time compensation module, and meal delivery difficulty time compensation module;
[0102] The step of determining the operation matrix of the compensation time layer according to the characteristic data corresponding to the target order, and calculating the target compensation time duration according to the fusion matrix and the operation matrix of the compensation time layer, comprises: determining the operation matrix of each compensation time module according to the characteristic data corresponding to the target order; respectively calculating the corresponding module compensation time duration according to the fusion matrix and the operation matrix of each compensation time module; and generating the target compensation time duration based on the calculated module compensation time duration.
[0103] That is to say, the time compensation durations of multiple modules can be calculated through multiple time compensation layers, and then the target time compensation duration can be calculated. This calculation rule can be a simple addition or a weighted addition.
[0104] S54: Generate the prediction result based on the regular duration and the target compensation time duration.
[0105] like Figure 4 As shown, the regular duration is the output of the regular compensation time layer, and the target compensation time is the output of the compensation time layer. The sum of the two is the predicted result of the delivery time of the target order.
[0106] In this embodiment, the calculation of the time compensation duration and the calculation of the conventional prediction both rely on the fusion matrix obtained after the previous feature fusion. In this way, when training the model, the time compensation layer and the conventional prediction layer can be optimized as a whole, and the optimization of the model is more convenient. In addition, since the fusion matrix is obtained based on multivariate features, the optimization of the model based on it is more comprehensive.
[0107] The present disclosure also provides a method for training a delivery time prediction model, as follows:
[0108] A first loss function is set for the compensation layer, and a second loss function is set for the conventional prediction layer, wherein the first loss function and the second loss function are of different function types;
[0109] Input the feature data related to order delivery in the sample data into the delivery time prediction model to be trained to obtain the prediction result of the delivery time to be tested;
[0110] Repeat the following steps to adjust the element values:
[0111] Adjusting the element values in the compensation layer operation matrix according to the actual delivery time in the sample data, the prediction result to be checked, and the first loss function;
[0112] Adjusting the element values in the operation matrix of the conventional prediction layer according to the actual delivery time in the sample data, the prediction result to be checked, and the second loss function;
[0113] Until the difference between the output of the first loss function before the element value adjustment operation and the output of the first loss function after the element value adjustment operation is less than the first preset threshold, and the difference between the output of the second loss function before the element value adjustment operation and the output of the second loss function after the element value adjustment operation is less than the second preset threshold, it is determined that the training of the delivery time prediction model is completed.
[0114] That is to say, during the training process, the loss function (Loss Function) set for the time compensation layer is different from the loss function set for the regular prediction layer. Specifically, the loss function for the time compensation layer can be set to an absolute value (abs) function, while the loss function for the regular prediction layer can be set to a variance (square) function.
[0115] In the case of Figure 4 When the model shown is optimized as a whole, the operation matrices in the four compensation modules of the compensation layer and the operation matrix in the conventional prediction layer can be adjusted in turn. Specifically, when adjusting the compensation layer, the elements in the compensation embedding vector can also be adjusted.
[0116] In this way, different loss functions can be set according to business needs, and targeted improvements and optimizations can be made according to the business.
[0117] Figure 6 1 is a block diagram of a device for calculating delivery time shown in an exemplary embodiment of the present disclosure. The device includes:
[0118] An acquisition module 610 is used to acquire pre-specified feature data related to order delivery, wherein the feature data includes sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to the target order, and the dense feature data includes delivery environment indicators and quantifiable information related to the target order;
[0119] A first data processing module 620, configured to generate a first feature matrix according to the sparse feature data and the dense feature data;
[0120] A second data processing module 630, configured to generate a second feature matrix according to the historical dense feature data;
[0121] The third data processing module 640 is used to input the first feature matrix and the second feature matrix into the delivery time prediction model to obtain a prediction result of the delivery time of the target order.
[0122] The above scheme can at least achieve the following technical effects:
[0123] By generating a first feature matrix based on the sparse feature data and the dense feature data related to order delivery, and generating a second feature matrix based on the historical dense feature data, the processed feature matrix is brought into the delivery time prediction model to obtain the prediction result of the delivery time of the target order. In this solution, in addition to being able to input sparse features including ID classes, historical dense features with time series can also be input for prediction, which improves the accuracy and globality of order delivery time prediction.
[0124] In a second aspect, the present disclosure provides a device for calculating a delivery time, the device comprising:
[0125] An acquisition module, used to acquire pre-specified feature data related to order delivery, wherein the feature data includes sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to the target order, and the dense feature data includes delivery environment indicators and quantifiable information related to the target order;
[0126] A first data processing module, used for generating a first feature matrix according to the sparse feature data and the dense feature data;
[0127] A second data processing module, used for generating a second feature matrix according to the historical dense feature data;
[0128] The third data processing module is used to input the first feature matrix and the second feature matrix into the delivery time prediction model to obtain a prediction result of the delivery time of the target order.
[0129] Optionally, the delivery time prediction model includes an FM algorithm layer, an MLP algorithm layer, a time series output layer, and a feature fusion layer;
[0130] The FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix;
[0131] The MLP algorithm layer is used to perform matrix transformation processing on the first feature matrix;
[0132] The time series output layer is used to perform matrix transformation processing on the second feature matrix;
[0133] The feature fusion layer is used to fuse the elements in the matrix output by the FM algorithm layer, the matrix output by the MLP algorithm layer and the matrix output by the time series output layer to obtain a fusion matrix; the prediction result is calculated based on the fusion matrix.
[0134] Optionally, the delivery time prediction model further includes a conventional prediction layer and a time compensation layer;
[0135] The prediction results are calculated based on the following steps:
[0136] A conventional duration is obtained by calculating the fusion matrix and the operation matrix of the conventional prediction layer;
[0137] Determine the operation matrix of the time compensation layer according to the characteristic data corresponding to the target order;
[0138] Calculate the target time compensation duration according to the fusion matrix and the operation matrix of the time compensation layer;
[0139] The prediction result is generated based on the regular duration and the target compensation time duration.
[0140] Optionally, the operation matrix of the time compensation layer determined according to the feature data corresponding to the target order includes:
[0141] Determine the attribute value corresponding to the time compensation layer according to the characteristic data;
[0142] Determining the data interval where the attribute value is located among a plurality of preset data intervals;
[0143] The operation matrix of the complementary time layer is calculated according to the difference between the attribute value and the two end values of the data interval, and the complementary time embedding vectors corresponding to the two end values respectively found in the complementary time embedding vector library, wherein the complementary time embedding vector library includes the complementary time embedding vectors corresponding to the preset data interval end values.
[0144] Optionally, the time compensation layer includes one or more of the following time compensation modules:
[0145] Load compensation time module, distance compensation time module, price compensation time module, and meal delivery difficulty compensation time module;
[0146] The step of determining the operation matrix of the compensation time layer according to the characteristic data corresponding to the target order, and calculating the target compensation time length according to the fusion matrix and the operation matrix of the compensation time layer includes:
[0147] Determine the operation matrix of each time-compensation module according to the characteristic data corresponding to the target order;
[0148] According to the fusion matrix and the operation matrix of each of the time compensation modules, the corresponding module time compensation duration is calculated respectively;
[0149] The target compensation time duration is generated based on the calculated module compensation time duration.
[0150] Optionally, the delivery time prediction model is trained in the following way:
[0151] A first loss function is set for the compensation layer, and a second loss function is set for the conventional prediction layer, wherein the first loss function and the second loss function are of different function types;
[0152] Input the feature data related to order delivery in the sample data into the delivery time prediction model to be trained to obtain the prediction result of the delivery time to be tested;
[0153] Repeat the following steps to adjust the element values:
[0154] Adjusting the element values in the operation matrix of the compensation layer according to the actual delivery time in the sample data, the prediction result to be checked, and the first loss function;
[0155] Adjusting the element values in the operation matrix of the conventional prediction layer according to the actual delivery time in the sample data, the prediction result to be checked, and the second loss function;
[0156] Until the difference between the output of the first loss function before the element value adjustment operation and the output of the first loss function after the element value adjustment operation is less than the first preset threshold, and the difference between the output of the second loss function before the element value adjustment operation and the output of the second loss function after the element value adjustment operation is less than the second preset threshold, it is determined that the training of the delivery time prediction model is completed.
[0157] Optionally, the sparse feature data includes a sparse index value and a sparse attribute value corresponding to each sparse feature, wherein the sparse attribute value is a preset value corresponding to the sparse feature;
[0158] The dense feature data includes a dense index value and a dense attribute value corresponding to each dense feature, wherein the dense attribute value is a quantized value corresponding to the dense feature;
[0159] The first data processing module is used for:
[0160] For each sparse feature, the following operations are performed: a sparse feature embedding vector is obtained by querying in a preset embedding vector library according to the sparse index value corresponding to the sparse feature, and a sparse feature vector corresponding to the sparse feature is generated according to the sparse attribute value and the sparse feature embedding vector;
[0161] For each dense feature, the following operations are performed: a dense feature embedding vector is obtained by querying in a preset embedding vector library according to the dense index value corresponding to the dense feature, and a dense feature vector corresponding to the dense feature is generated according to the dense attribute value and the dense feature embedding vector;
[0162] The first feature matrix is generated based on the sparse index value and the dense index value, and the generated sparse feature vector and the dense feature vector.
[0163] Optionally, the FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix, including:
[0164] The combination of any two of the features is taken as a new feature, and the following operations are performed on the new feature:
[0165] Taking the dot product of the feature vectors corresponding to the two features as the attribute value of the new feature;
[0166] Generate a feature vector corresponding to the new feature based on the corresponding feature vectors of the two features and the attribute value;
[0167] The matrix output by the FM algorithm layer includes feature vectors corresponding to the new features.
[0168] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units (modules) is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units (modules) as needed, that is, the internal structure of the device can be divided into different functional units (modules) to complete all or part of the functions described above.
[0169] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0170] The present disclosure provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, the steps of any one of the methods for calculating the delivery time are implemented.
[0171] The present disclosure provides an electronic device, comprising:
[0172] a memory having a computer program stored thereon;
[0173] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods for calculating the delivery time.
[0174] Figure 7 FIG. 1 is a block diagram of an electronic device according to an exemplary embodiment. Figure 7 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0175] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned method for calculating the delivery time. The memory 702 is used to store various types of data to support the operation of the electronic device 700. For example, these data may include instructions for any application or method operating on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc., and for example, order price, order initiation time, delivery address information, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent via the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the above-mentioned other interface modules can be a keyboard, a mouse, buttons, etc. These buttons can be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0176] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned method for calculating delivery time.
[0177] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for calculating the delivery time are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions can be executed by the processor 701 of the electronic device 700 to complete the above-mentioned method for calculating the delivery time.
[0178] Figure 8 8 is a block diagram of an electronic device according to an exemplary embodiment. For example, the electronic device 800 may be provided as a server. Figure 8 The electronic device 800 includes a processor 822, which may be one or more, and a memory 832 for storing a computer program executable by the processor 822. The computer program stored in the memory 832 may include one or more modules each corresponding to a set of instructions. In addition, the processor 822 may be configured to execute the computer program to perform the above-mentioned method for calculating the delivery time.
[0179] In addition, the electronic device 800 may further include a power supply component 826 and a communication component 850, wherein the power supply component 826 may be configured to perform power management of the electronic device 800, and the communication component 850 may be configured to implement communication of the electronic device 800, for example, wired or wireless communication. In addition, the electronic device 800 may further include an input / output (I / O) interface 858. The electronic device 800 may operate based on an operating system stored in the memory 832, such as Windows ServerTM, Mac OSXTM, UnixTM, LinuxTM, etc.
[0180] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for calculating the delivery time are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 832 including program instructions, and the above-mentioned program instructions can be executed by the processor 822 of the electronic device 800 to complete the above-mentioned method for calculating the delivery time.
[0181] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned method for calculating the delivery time when executed by the programmable device.
[0182] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0183] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0184] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A method for calculating delivery time, characterized in that: The method comprises: Acquire pre-specified feature data related to order delivery, wherein the feature data includes sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to the target order, and the dense feature data includes delivery environment indicators and quantifiable information related to the target order; Generate a first feature matrix according to the sparse feature data and the dense feature data; generating a second feature matrix according to the dense feature data of the history; Inputting the first feature matrix and the second feature matrix into a delivery time prediction model to obtain a prediction result of the delivery time of the target order, wherein the delivery time prediction model includes an FM algorithm layer, an MLP algorithm layer, a time series output layer, and a feature fusion layer; The FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix; The MLP algorithm layer is used to perform matrix transformation processing on the first feature matrix; The time series output layer is used to perform matrix transformation processing on the second feature matrix; The feature fusion layer is used to fuse the elements in the matrix output by the FM algorithm layer, the matrix output by the MLP algorithm layer and the matrix output by the time series output layer to obtain a fusion matrix; the prediction result is calculated based on the fusion matrix; The sparse feature data includes a sparse index value and a sparse attribute value corresponding to each sparse feature, wherein the sparse attribute value is a preset value corresponding to the sparse feature; The dense feature data includes a dense index value and a dense attribute value corresponding to each dense feature, wherein the dense attribute value is a quantized value corresponding to the dense feature; The step of generating a first feature matrix according to the sparse feature data and the dense feature data includes: For each sparse feature, the following operations are performed: a sparse feature embedding vector is obtained by querying in a preset embedding vector library according to the sparse index value corresponding to the sparse feature, and a sparse feature vector corresponding to the sparse feature is generated according to the sparse attribute value and the sparse feature embedding vector; For each dense feature, the following operations are performed: a dense feature embedding vector is obtained by querying in a preset embedding vector library according to the dense index value corresponding to the dense feature, and a dense feature vector corresponding to the dense feature is generated according to the dense attribute value and the dense feature embedding vector; Generate the first feature matrix based on the sparse index value and the dense index value, and the generated sparse feature vector and the dense feature vector; The FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix, including: The combination of any two of the features is taken as a new feature, and the following operations are performed on the new feature: Taking the dot product of the corresponding feature vectors of the two features as the attribute value of the new feature; Generate a feature vector corresponding to the new feature based on the corresponding feature vectors of the two features and the attribute value; The matrix output by the FM algorithm layer includes feature vectors corresponding to the new features.
2. The method according to claim 1, characterized in that: The delivery time prediction model also includes a conventional prediction layer and a time compensation layer; The prediction results are calculated based on the following steps: A conventional duration is obtained by calculating the fusion matrix and the operation matrix of the conventional prediction layer; Determine the operation matrix of the time compensation layer according to the characteristic data corresponding to the target order; Calculate the target time compensation duration according to the fusion matrix and the operation matrix of the time compensation layer; The prediction result is generated based on the regular duration and the target compensation time duration.
3. The method according to claim 2, characterized in that The operation matrix of the time compensation layer determined according to the characteristic data corresponding to the target order includes: Determine the attribute value corresponding to the time compensation layer according to the characteristic data; Determining the data interval where the attribute value is located among a plurality of preset data intervals; The operation matrix of the complementary time layer is calculated according to the difference between the attribute value and the two end values of the data interval, and the complementary time embedding vectors corresponding to the two end values respectively found in the complementary time embedding vector library, wherein the complementary time embedding vector library includes the complementary time embedding vectors corresponding to the end values of the preset data interval.
4. The method according to claim 2, characterized in that: The time compensation layer includes one or more of the following time compensation modules: Load compensation time module, distance compensation time module, price compensation time module, and meal delivery difficulty compensation time module; The step of determining the operation matrix of the compensation time layer according to the characteristic data corresponding to the target order, and calculating the target compensation time length according to the fusion matrix and the operation matrix of the compensation time layer includes: Determine the operation matrix of each time-compensation module according to the characteristic data corresponding to the target order; According to the fusion matrix and the operation matrix of each of the time compensation modules, the corresponding module time compensation duration is calculated respectively; The target compensation time duration is generated based on the calculated module compensation time duration.
5. The method according to claim 2, characterized in that: The delivery time prediction model is trained in the following way: A first loss function is set for the compensation layer, and a second loss function is set for the conventional prediction layer, wherein the first loss function and the second loss function are of different function types; Input the feature data related to order delivery in the sample data into the delivery time prediction model to be trained to obtain the prediction result of the delivery time to be tested; Repeat the following steps to adjust the element values: Adjusting the element values in the operation matrix of the compensation layer according to the actual delivery time in the sample data, the prediction result to be checked, and the first loss function; Adjusting the element values in the operation matrix of the conventional prediction layer according to the actual delivery time in the sample data, the prediction result to be checked, and the second loss function; Until the difference between the output of the first loss function before the element value adjustment operation and the output of the first loss function after the element value adjustment operation is less than the first preset threshold, and the difference between the output of the second loss function before the element value adjustment operation and the output of the second loss function after the element value adjustment operation is less than the second preset threshold, it is determined that the training of the delivery time prediction model is completed.
6. A device for calculating delivery time, characterized in that: The device comprises: An acquisition module, used to acquire pre-specified feature data related to order delivery, wherein the feature data includes sparse feature data and dense feature data, wherein the sparse feature data refers to non-quantifiable information related to the target order, and the dense feature data includes delivery environment indicators and quantifiable information related to the target order; A first data processing module, used for generating a first feature matrix according to the sparse feature data and the dense feature data; A second data processing module, used for generating a second feature matrix according to the historical dense feature data; A third data processing module is used to input the first feature matrix and the second feature matrix into a delivery time prediction model to obtain a prediction result of the delivery time of the target order; The delivery time prediction model includes an FM algorithm layer, an MLP algorithm layer, a time series output layer, and a feature fusion layer; The FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix; The MLP algorithm layer is used to perform matrix transformation processing on the first feature matrix; The time series output layer is used to perform matrix transformation processing on the second feature matrix; The feature fusion layer is used to fuse the elements in the matrix output by the FM algorithm layer, the matrix output by the MLP algorithm layer and the matrix output by the time series output layer to obtain a fusion matrix; the prediction result is calculated based on the fusion matrix; The sparse feature data includes a sparse index value and a sparse attribute value corresponding to each sparse feature, wherein the sparse attribute value is a preset value corresponding to the sparse feature; The dense feature data includes a dense index value and a dense attribute value corresponding to each dense feature, wherein the dense attribute value is a quantized value corresponding to the dense feature; The step of generating a first feature matrix according to the sparse feature data and the dense feature data includes: For each sparse feature, the following operations are performed: a sparse feature embedding vector is obtained by querying in a preset embedding vector library according to the sparse index value corresponding to the sparse feature, and a sparse feature vector corresponding to the sparse feature is generated according to the sparse attribute value and the sparse feature embedding vector; For each dense feature, the following operations are performed: a dense feature embedding vector is obtained by querying in a preset embedding vector library according to the dense index value corresponding to the dense feature, and a dense feature vector corresponding to the dense feature is generated according to the dense attribute value and the dense feature embedding vector; Generate the first feature matrix based on the sparse index value and the dense index value, and the generated sparse feature vector and the dense feature vector; The FM algorithm layer is used to perform cross-combination feature expansion on the first feature matrix, including: The combination of any two of the features is taken as a new feature, and the following operations are performed on the new feature: Taking the dot product of the corresponding feature vectors of the two features as the attribute value of the new feature; Generate a feature vector corresponding to the new feature based on the corresponding feature vectors of the two features and the attribute value; The matrix output by the FM algorithm layer includes feature vectors corresponding to the new features.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 5 are implemented.
8. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Take-out delivery time prediction method and device
CN108364085A