Method and device for cash advance recognition
Embodiments of the application provide a method and device for training a cash-return recognition model and a method and device for cash-return recognition, the training method comprises: acquiring first transaction information of a first transaction and a first cash-return label value of the first transaction; calculating a first cash-return predictive value for the first transaction, and a Q-value's label value corresponding to the first transaction information and the first cash-return predictive value; and training a Deep Q-Network (DQN) by adjusting parameters of the DQN such that an absolute value of a difference between a first Q-value's predictive value output by the trained DQN and the Q-value's label value is smaller than that between the first Q-value's predictive value output by the untrained DQN and the Q-value's label value, the first Q-value's predictive value obtained by inputting the first transaction information and the first cash-return predictive value to the DQN.
1. A method for training a cash-return recognition model, the cash-return recognition model comprising a first Deep Q-Network (DQN) and a second DQN, the method comprising:
acquiring first transaction information of a first transaction and a first cash-return label value of the first transaction, the first cash-return label value indicating whether the first transaction is labeled as a cash-return transaction;
calculating a first cash-return predictive value for the first transaction by inputting the first transaction information to the first DQN, the first cash-return predictive value indicating whether the first transaction is predicted to be a cash-return transaction;
calculating a Q-value's label value corresponding to the first transaction information and the first cash-return predictive value by using a Q learning algorithm based on the first DQN and the first cash-return label value; and
training the second DQN based on the first transaction information, the first cash-return predictive value, and the Q-value's label value by adjusting parameters of the second DQN such that an absolute value of a difference between a first Q-value's predictive value output by the second DQN after the training and the Q-value's label value is smaller than that between the first Q-value's predictive value output by the second DQN before the training and the Q-value's label value, wherein the first Q-value's predictive value is output by inputting the first transaction information and the first cash-return predictive value to the second DQN after the training, and the first Q-value's predictive value corresponds to the first transaction information and the first cash-return predictive value.
2. The method for training a cash-return recognition model according to claim 1 , wherein calculating the first cash-return predictive value for the first transaction comprises:
inputting the first transaction information to the first DQN to obtain a two-dimensional vector of Q-value's predictive values; and
calculating the first cash-return predictive value according to a s-greedy policy based on the vector.
3. The method for training a cash-return recognition model according to claim 1 , wherein the first transaction information comprises a transaction amount, and wherein calculating a Q-value's label value corresponding to the first transaction information and the first cash-return predictive value by using a Q learning algorithm comprises:
acquiring second transaction information of a second transaction and a second cash-return label value of the second transaction, the second cash-return label value indicating whether the second transaction is labeled as a cash-return transaction;
determining a return value for the first transaction based on the first cash-return predictive value, the first cash-return label value, and the transaction amount;
inputting the second transaction information to the first DQN to obtain a second Q-value's predictive value corresponding to the second transaction information and the second cash-return label value; and
calculating the Q-value's label value corresponding to the first transaction information and the first cash-return predictive value based on the return value and the second Q-value's predictive value.
4. The method for training a cash-return recognition model according to claim 3 , wherein inputting the second transaction information to the first DQN to obtain the second Q-value's predictive value corresponding to the second transaction information and the second cash-return label value comprises:
inputting the second transaction information to the first DQN to obtain a two-dimensional vector of Q-value's predictive values corresponding to the second transaction information;
performing one-hot encoding on the second cash-return label value to obtain a two-dimensional vector corresponding to the second cash-return label value;
performing an element-wise multiplication on the vector of Q-value's predictive values and the vector corresponding to the second cash-return label value to obtain a two-dimensional joint characterization vector; and
selecting a non-zero value in the joint characterization vector as the second Q-value's predictive value.
5. The method for training a cash-return recognition model according to claim 3 , wherein determining the return value for the first transaction based on the first cash-return predictive value, the first cash-return label value, and the transaction amount comprises:
in response to that the first cash-return predictive value is consistent with the first cash-return label value, determining the return value for the first transaction to be the transaction amount; and
in response to that the first cash-return predictive value is inconsistent with the first cash-return label value, determining the return value for the first transaction to be the negative of the transaction amount.
6. The method for training a cash-return recognition model according to claim 3 , further comprising adding the return value for the first transaction to a total return value of the model after determining the return value.
7. The method for training a cash-return recognition model according to claim 1 , wherein the cash-return recognition model further comprises a sample queue including a number of samples in sequence, the method further comprises:
updating the sample queue by deleting a predetermined number of existing samples ranked in the front from the sample queue when receiving a predetermined number of new samples.
8. The method for training a cash-return recognition model according to claim 7 , wherein the method further comprises:
preparing the samples in the sample queue, each sample including a transaction's information, a cash-return predictive value of the transaction, and a Q-value's label value corresponding to the transaction's information and the cash-return predictive value.
9. The method for training a cash-return recognition model according to claim 1 , wherein the first transaction information comprises attribute information, a buyer's information, a seller's information, and logistics information of the first transaction.
10. The method for training a cash-return recognition model according to claim 1 , wherein the first DQN or the second DQN comprises one of the following neural networks: an Long Short-Term Memory (LSTM) network, a Deep Neural Network (DNN), a Convolutional Neural Network (CNN), and an Recurrent Neural Network (RNN).
11. The method for training a cash-return recognition model according to claim 1 , wherein training the second DQN based on the first transaction information, the first cash-return predictive value, and the Q-value's label value comprises training the second DQN by a stochastic gradient descent algorithm.
12. The method for training a cash-return recognition model according to claim 1 , further comprising setting parameters of the first DQN based on the parameters of the second DQN.
13. The method for training a cash-return recognition model according to claim 1 , wherein the first DQN and the second DQN are interchangeable.
14. A method for cash-return recognition, comprising:
acquiring first transaction information of a first transaction and a first cash-return label value of the first transaction, the first cash-return label value indicating whether the first transaction is labeled as a cash-return transaction;
calculating a first cash-return predictive value for the first transaction by inputting the first transaction information to a first Deep Q-Network (DQN), the first cash-return predictive value indicating whether the first transaction is predicted to be a cash-return transaction;
calculating a Q-value's label value corresponding to the first transaction information and the first cash-return predictive value by using a Q learning algorithm based on the first DQN and the first cash-return label value; and
training a second DON based on the first transaction information, the first cash-return predictive value, and the Q-value's label value by adjusting parameters of the second DQN such that a difference between a Q-value's predictive value output by the second DQN and the Q-value's label value decreases after the training;
assigning the parameters of the second DQN to the first DQN;
acquiring transaction information of a transaction; and
inputting the transaction information to the first DQN to obtain a cash-return predictive value for the transaction, the cash-return predictive value indicating whether the transaction is predicted to be a cash-return transaction.
15. The method for cash-return recognition according to claim 14 , wherein inputting the transaction information to the first DQN to obtain the cash-return predictive value for the transaction comprises:
inputting the transaction information to the first DQN to obtain a two-dimensional vector of Q-value's predictive values corresponding to the transaction information; and
calculating the cash-return predictive value for the transaction according to a s-greedy policy based on the vector.
16. A device for training a cash-return recognition model, the cash-return recognition model comprising a first Deep Q-Network (DQN) and a second DQN, wherein the device comprises one or more processors and one or more non-transitory computer-readable memories coupled to the one or more processors and configured with instructions executable by the one or more processors to cause the device to perform operations comprising:
acquiring first transaction information of a first transaction and a first cash-return label value of the first transaction, the first cash-return label value indicating whether the first transaction is labeled as a cash-return transaction;
calculating a first cash-return predictive value for the first transaction by inputting the first transaction information to the first DQN, the first cash-return predictive value indicating whether the first transaction is predicted to be a cash-return transaction;
calculating a Q-value's label value corresponding to the first transaction information and the first cash-return predictive value by using a Q learning algorithm based on the first DQN and the first cash-return label value; and
training the second DQN based on the first transaction information, the first cash-return predictive value, and the Q-value's label value by adjusting parameters of the second DQN such that an absolute value of a difference between a first Q-value's predictive value output by the second DQN after the training and the Q-value's label value is smaller than that between the first Q-value's predictive value output by the second DQN before the training and the Q-value's label value, wherein the first Q-value's predictive value is output by inputting the first transaction information and the first cash-return predictive value to the second DQN after the training, and the first Q-value's predictive value corresponds to the first transaction information and the first cash-return predictive value.
17. The device for training a cash-return recognition model according to claim 16 , wherein calculating the first cash-return predictive value for the first transaction comprises:
inputting the first transaction information to the first DQN to obtain a two-dimensional vector of Q-value's predictive values; and
calculating the first cash-return predictive value according to a s-greedy policy based on the vector.
18. The device for training a cash-return recognition model according to claim 16 , wherein the first transaction information comprises a transaction amount, and wherein calculating a Q-value's label value corresponding to the first transaction information and the first cash-return predictive value by using a Q learning algorithm comprises:
acquiring second transaction information of a second transaction and a second cash-return label value of the second transaction, the second cash-return label value indicating whether the second transaction is labeled as a cash-return transaction;
determining a return value for the first transaction based on the first cash-return predictive value, the first cash-return label value, and the transaction amount;
inputting the second transaction information to the first DQN to obtain a second Q-value's predictive value corresponding to the second transaction information and the second cash-return label value; and
calculating the Q-value's label value corresponding to the first transaction information and the first cash-return predictive value based on the return value and the second Q-value's predictive value.
19. The device for training a cash-return recognition model according to claim 18 , wherein inputting the second transaction information to the first DQN to obtain the second Q-value's predictive value corresponding to the second transaction information and the second cash-return label value comprises:
inputting the second transaction information to the first DQN to obtain a two-dimensional vector of Q-value's predictive values corresponding to the second transaction information;
performing one-hot encoding on the second cash-return label value to obtain a two-dimensional vector corresponding to the second cash-return label value;
performing an element-wise multiplication on the vector of Q-value's predictive values and the vector corresponding to the second cash-return label value to obtain a two-dimensional joint characterization vector; and
selecting a non-zero value in the joint characterization vector as the second Q-value's predictive value.
20. The device for training a cash-return recognition model according to claim 18 , wherein determining the return value for the first transaction based on the first cash-return predictive value, the first cash-return label value, and the transaction amount comprises:
in response to that the first cash-return predictive value is consistent with the first cash-return label value, determining the return value for the first transaction to be the transaction amount; and
in response to that the first cash-return predictive value is inconsistent with the first cash-return label value, determining the return value for the first transaction to be the negative of the transaction amount.