Decision tree training method, waybill type identification method and device, equipment, and medium
The waybill identification model is built through the decision tree training method, which solves the problem of low efficiency and error-prone waybill type identification in the logistics system, realizes automatic identification and efficient identification, and provides a lightweight and fast waybill type identification solution.
Patent Information
- Application Number
- CN202210322056.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-03-29
AI Technical Summary
The waybill type identification method in the existing logistics system mainly relies on manual observation, which is slow. The increase in the amount of data and waybill types leads to an increase in workload. It is difficult to complete the identification work in a short period of time and is prone to identification errors.
The decision tree training method is used to generate a target training sample set, allocate the waybill flag data to the decision tree, use the preset algorithm to segment features, and iteratively segment sub-nodes until the preset termination conditions are met to build a suitable decision tree model. And perform pruning to improve recognition efficiency.
It realizes the automatic identification of waybill types, improves the identification accuracy and efficiency, and avoids the problems of low manual identification efficiency and easy identification errors. The decision tree model structure is lightweight, the identification speed is faster, and it is not easy to overfit.
Smart Images

Figure CN114692871B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of smart logistics technology, and specifically to a decision tree training method and device, a waybill type identification method and device, an electronic device, a computer storage medium, and a program product. Background Art
[0002] In logistics management, waybills are divided into multiple waybill types, and the waybill type needs to be identified based on the waybill flag.
[0003] In the process of realizing the concept disclosed in the present invention, the inventors found that there are at least the following problems in the related technology: in the current waybill type identification method of the logistics system, the waybill type is mainly identified by manually observing the characteristics of the waybill flag, and the identification speed is slow. The increase in data volume and waybill types will also increase the workload of staff, making it difficult to complete the waybill identification work in a short period of time. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a decision tree training method and device, a waybill type identification method and device, an electronic device, a computer storage medium and a program product.
[0005] According to a first aspect of the present disclosure, a method for training a decision tree for identifying a waybill type is provided, comprising:
[0006] Generate a target training sample set according to multiple waybill flag data, wherein each waybill flag data includes data corresponding to multiple feature bits, and the feature bits are used to identify the waybill type;
[0007] Assign the target training sample set to the root node in the decision tree;
[0008] Using a preset algorithm to assign a target segmentation feature to a sub-node to be assigned a segmentation feature in the decision tree, wherein the target segmentation feature is used to segment the waybill flag bit data in the sub-node to be assigned a segmentation feature based on the data corresponding to the target feature bit;
[0009] Based on the target segmentation feature, segment the waybill flag data in the child node to be assigned the segmentation feature to obtain the waybill flag data corresponding to the next child node to be assigned the segmentation feature;
[0010] The iterative execution uses the preset algorithm to assign the next target segmentation feature to the child node of the next segmentation feature to be assigned, and based on the next target segmentation feature, the waybill flag data in the child node of the next segmentation feature to be assigned is segmented until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
[0011] According to an embodiment of the present disclosure, using a preset algorithm to assign a target segmentation feature to a sub-node to be assigned a segmentation feature in a decision tree includes:
[0012] Using a preset algorithm, the waybill flag bit data contained in the sub-node to which the segmentation feature is to be assigned is processed to obtain a Gini value corresponding to each feature bit associated with the sub-node to which the segmentation feature is to be assigned;
[0013] The data corresponding to the feature bit whose Gini value meets the preset numerical discrimination condition is determined as the target segmentation feature.
[0014] According to an embodiment of the present disclosure, processing the waybill flag bit data contained in the sub-node to which the segmentation feature is to be assigned to obtain the Gini value corresponding to each feature bit associated with the sub-node to which the segmentation feature is to be assigned includes:
[0015] Parallel processing nodes are used to perform in parallel: the waybill flag bit data contained in the child node to be assigned the segmentation feature is processed to obtain the Gini value corresponding to each feature bit associated with the child node to be assigned the segmentation feature, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein
[0016] A single computing node is used to: determine the waybill types contained in the waybill flag data assigned to the single computing node, and the quantity of each waybill type;
[0017] The statistical node is used to: summarize the calculation results of multiple calculation nodes to obtain the number of each waybill type associated with the sub-node of the segmentation feature to be assigned, and calculate the Gini value corresponding to each feature bit associated with the sub-node of the segmentation feature to be assigned based on the number of each waybill type associated with the sub-node of the segmentation feature to be assigned.
[0018] According to an embodiment of the present disclosure, the above method further includes:
[0019] Prune the trained decision tree to obtain the target decision tree.
[0020] According to an embodiment of the present disclosure, pruning a trained decision tree to obtain a target decision tree includes:
[0021] Utilize parallel processing nodes to perform in parallel: determine the recognition result of each leaf node for the waybill flag data in the trained decision tree, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein a single computing node is used to parallelly calculate the recognition result of each leaf node assigned to the single computing node, and the statistical node is used to summarize the recognition results of the same leaf node, so as to obtain the recognition result of each leaf node for the waybill flag data in the trained decision tree;
[0022] Determine the recognition error rate of each leaf node according to the recognition result of each leaf node on the waybill flag data and the actual waybill type of the waybill flag data associated with each leaf node;
[0023] The leaf nodes whose recognition error rate is greater than the preset error rate threshold are removed to obtain the target decision tree.
[0024] According to an embodiment of the present disclosure, generating a target training sample set according to a plurality of waybill flag data includes:
[0025] Discretize multiple waybill flag data to obtain two training sample subsets;
[0026] A target training sample set is determined from the two training sample subsets.
[0027] According to an embodiment of the present disclosure, a plurality of waybill flag data are discretized to obtain two training sample subsets including:
[0028] Sort multiple waybill flag data to obtain a sample sequence;
[0029] The operation of determining a plurality of initial breakpoints of the sample sequence is performed in parallel using a parallel processing node;
[0030] Determine a target breakpoint based on a plurality of initial breakpoints;
[0031] The sample sequence is split into two according to the target breakpoint to obtain two training sample subsets.
[0032] A second aspect of the present disclosure provides a method for identifying a waybill type by applying a decision tree, comprising:
[0033] Get the waybill flag data to be identified;
[0034] Input the waybill flag data to be identified into the decision tree trained using the above method;
[0035] Use the decision tree to output the waybill type of the waybill flag data to be identified.
[0036] A third aspect of the present disclosure provides a device for training a decision tree for identifying a waybill type, comprising a generation module, a first allocation module, a second allocation module, a segmentation module, and an iteration module.
[0037] Among them, the generation module is used to generate a target training sample set according to multiple waybill flag data, wherein each waybill flag data includes data corresponding to multiple feature bits, and the feature bits are used to identify the waybill type;
[0038] A first allocation module, used for allocating a target training sample set to a root node in a decision tree;
[0039] The second allocation module is used to allocate the target segmentation feature to the sub-nodes to be allocated the segmentation feature in the decision tree using a preset algorithm, wherein the target segmentation feature is used to segment the waybill flag bit data in the sub-nodes to be allocated the segmentation feature based on the data corresponding to the target feature bit;
[0040] A segmentation module, for segmenting the waybill flag data in the subnode to be assigned the segmentation feature based on the target segmentation feature, so as to obtain the waybill flag data corresponding to the next subnode to be assigned the segmentation feature;
[0041] The iteration module is used to iteratively execute the preset algorithm to assign the next target segmentation feature to the child node of the next segmentation feature to be assigned, and based on the next target segmentation feature, segment the waybill flag data in the child node of the next segmentation feature to be assigned, until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
[0042] According to an embodiment of the present disclosure, the second allocation module includes a first processing unit and a first determining unit.
[0043] The first processing unit is used to process the waybill flag bit data contained in the sub-node to which the segmentation feature is to be assigned using a preset algorithm to obtain a Gini value corresponding to each feature bit associated with the sub-node to which the segmentation feature is to be assigned;
[0044] The first determining unit is used to determine data corresponding to a feature bit whose Gini value meets a preset numerical discrimination condition as a target segmentation feature.
[0045] According to an embodiment of the present disclosure, the first processing unit includes a first execution subunit.
[0046] The first execution subunit is used to perform in parallel using parallel processing nodes: processing the waybill flag bit data contained in the subnode to which the segmentation feature is to be assigned to obtain the Gini value corresponding to each feature bit associated with the subnode to which the segmentation feature is to be assigned, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein
[0047] A single computing node is used to: determine the waybill types contained in the waybill flag data assigned to the single computing node, and the quantity of each waybill type;
[0048] The statistical node is used to: summarize the calculation results of multiple calculation nodes to obtain the number of each waybill type associated with the sub-node of the segmentation feature to be assigned, and calculate the Gini value corresponding to each feature bit associated with the sub-node of the segmentation feature to be assigned based on the number of each waybill type associated with the sub-node of the segmentation feature to be assigned.
[0049] According to an embodiment of the present disclosure, the above-mentioned device also includes a pruning module, which is used to prune the trained decision tree to obtain a target decision tree.
[0050] According to an embodiment of the present disclosure, the pruning module includes an execution unit, a second determination unit and a removal unit.
[0051] Wherein, the execution unit is used to perform in parallel using the parallel processing nodes: determining the recognition result of each leaf node for the waybill flag data in the trained decision tree, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein a single computing node is used to parallelly calculate the recognition result of each leaf node assigned to the single computing node, and the statistical node is used to summarize the recognition results of the same leaf node to obtain the recognition result of each leaf node for the waybill flag data in the trained decision tree;
[0052] A second determination unit is used to determine the recognition error rate of each leaf node according to the recognition result of each leaf node on the waybill flag data and the actual waybill type of the waybill flag data associated with each leaf node;
[0053] The removal unit is used to remove leaf nodes whose recognition error rate is greater than a preset error rate threshold to obtain a target decision tree.
[0054] According to an embodiment of the present disclosure, the generating module includes a second processing unit and a third determining unit.
[0055] The second processing unit is used to discretize the multiple waybill flag data to obtain two training sample subsets;
[0056] The third determining unit is used to determine a target training sample set from the two training sample subsets.
[0057] According to an embodiment of the present disclosure, the second processing unit includes a sorting subunit, a second execution subunit, a determination subunit and a segmentation subunit.
[0058] The sorting subunit is used to sort the multiple waybill flag data to obtain a sample sequence;
[0059] A second execution subunit, configured to use parallel processing nodes to perform operations of determining multiple initial breakpoints of a sample sequence in parallel;
[0060] A determination subunit, used for determining a target breakpoint according to a plurality of initial breakpoints;
[0061] The segmentation subunit is used to split the sample sequence into two according to the target breakpoint to obtain two training sample subsets.
[0062] A fourth aspect of the present disclosure provides a device for identifying waybill types using a decision tree, including an acquisition module, an input module, and an output module.
[0063] The acquisition module is used to obtain the waybill flag data to be identified;
[0064] An input module, used to input the waybill flag data to be identified into the decision tree trained using the above method;
[0065] The output module is used to output the waybill type of the waybill flag data to be identified by using the decision tree.
[0066] A fifth aspect of the present disclosure provides an electronic device, comprising: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above-mentioned method of training a decision tree for identifying waybill types.
[0067] The sixth aspect of the present disclosure also provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned method of training a decision tree for identifying waybill types.
[0068] A seventh aspect of the present disclosure also provides a computer program product, including a computer program, which, when executed by a processor, implements the above-mentioned method of training a decision tree for identifying waybill types.
[0069] According to the embodiments of the present disclosure, according to the embodiments of the present disclosure, in the above-mentioned training method, the target segmentation feature is used to segment the waybill flag bit data in the subnode to which the segmentation feature is to be assigned based on the data corresponding to the target feature bit, and the decision tree is trained by determining the target segmentation feature, so that a decision tree suitable for the waybill identification application scenario of the embodiment of the present disclosure can be constructed, and when the trained decision tree is used to identify the waybill type later, it can be accurate to use a certain bit in the waybill flag bit data to classify the waybill layer by layer, improve the recognition accuracy, and realize the automatic recognition of the waybill type, improve the recognition efficiency, and avoid the problems of low recognition efficiency of manual recognition methods, difficulty in recognition when there are many feature bits of the waybill flag data, and easy recognition errors. In addition, compared with the artificial decision tree, the decision tree model trained by the preset algorithm has a lightweight structure, no redundant nodes, faster recognition speed, and is not easy to overfit, and the training speed is also faster, with strong practicality, providing technical support for the recognition of waybill types in the logistics system. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] The above contents and other purposes, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0071] Figure 1 A diagram schematically illustrates an application scenario of a method, apparatus, device, medium, and program product for training a decision tree for identifying waybill types according to an embodiment of the present disclosure;
[0072] Figure 2 A flowchart of a method for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown;
[0073] Figure 3 A schematic diagram schematically shows how to use MapReduce to perform statistics on data according to an embodiment of the present disclosure;
[0074] Figure 4 A flowchart of a method for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown;
[0075] Figure 5 A structural block diagram schematically shows a device for training a decision tree for identifying waybill types according to an embodiment of the present disclosure; and
[0076] Figure 6 A block diagram of an electronic device suitable for implementing a method for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0077] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0078] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0079] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0080] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0081] In logistics management, waybills are divided into multiple waybill types. To effectively manage waybills, the waybill flag (WayBillSign) needs to be marked on the waybills, and the waybill type needs to be identified based on the waybill flag.
[0082] In the current logistics system, the waybill type recognition method mainly relies on manual observation of the characteristics of the waybill flag to identify the waybill type. In the current logistics system, the waybill type recognition method mainly relies on manual observation of the characteristics of the waybill flag to identify the waybill type. This method analyzes and compares the flags of different waybill types, selects the flag features that can be classified, and then identifies the waybill type. It has the advantages of being simple to implement, easy to understand, and convenient to modify.
[0083] Although the manual judgment scheme has the advantages of being simple to implement and easy to understand, it also has some disadvantages, such as slow recognition speed, the increase in data volume and waybill types will also increase the workload of staff, and it is difficult to complete the waybill recognition work in a short period of time. For a waybill flag bit with a length of n, if the manual method is used to screen the features, the algorithm complexity is o(2 n ), it is basically impossible to select the most appropriate identification features. And because manual identification is highly subjective, with the increase in the amount of waybill data and waybill types, when performing feature selection, some important features are often overlooked, and the correlation and complementarity between the features are ignored, which is easy to make mistakes. When the waybill type is identified incorrectly, it will have a negative impact on the logistics system that cannot be ignored.
[0084] In the related technology, for example, the method of manually constructing decision trees can be used to solve the problems existing in full manual recognition. There are many problems with artificial decision trees, such as complex model structure and slow recognition speed. At the same time, with the increase in the amount of data, there are also many problems in the construction of decision trees, such as the risk of overfitting. Although the artificially constructed decision tree is simple to implement, it will cause an increase in the amount of background code and redundancy in code implementation during the implementation process. The increase in model depth has a certain impact on the running speed.
[0085] Therefore, developing an automatic waybill type identification method with high accuracy, high operating efficiency and strong robustness has important application value and research significance.
[0086] In view of this, one aspect of the embodiments of the present disclosure provides a method for training a decision tree for identifying waybill types, comprising:
[0087] Generate a target training sample set according to multiple waybill flag data, wherein each waybill flag data includes data corresponding to multiple feature bits, and the feature bits are used to identify the waybill type;
[0088] Assign the target training sample set to the root node in the decision tree;
[0089] Using a preset algorithm to assign a target segmentation feature to a sub-node to be assigned a segmentation feature in the decision tree, wherein the target segmentation feature is used to segment the waybill flag bit data in the sub-node to be assigned a segmentation feature based on the data corresponding to the target feature bit;
[0090] Based on the target segmentation feature, segment the waybill flag data in the child node to be assigned the segmentation feature to obtain the waybill flag data corresponding to the next child node to be assigned the segmentation feature;
[0091] The iterative execution uses the preset algorithm to assign the next target segmentation feature to the child node of the next segmentation feature to be assigned, and based on the next target segmentation feature, the waybill flag data in the child node of the next segmentation feature to be assigned is segmented until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
[0092] Figure 1 The application scenario diagram of the method, apparatus, device, medium and program product for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown.
[0093] like Figure 1 As shown, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0094] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0095] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0096] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0097] In the application scenario of the present disclosure, the user can interact with the server 105 through the terminal devices 101, 102, and 103 through the network 104, and initiate a method request to the server for executing the method of training a decision tree for identifying the type of waybills according to the embodiment of the present disclosure. For example, the user can input various parameters required for training through the terminal devices 101, 102, and 103, and transmit training sample data to the server 105. In response to the user request, the server 105 executes the method of training the decision tree according to the embodiment of the present disclosure, for example: generating a target training sample set based on multiple training sample data, namely, waybill flag data, assigning the target training sample set to each node in the decision tree, and iteratively executing the operations of assigning target segmentation features using a preset algorithm to each sub-node, and segmenting the waybill flag data in the sub-node based on the target segmentation features, until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
[0098] It should be noted that the training method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the training device provided in the embodiment of the present disclosure can generally be set in the server 105. The training method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the training device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0099] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0100] The following will be based on Figure 1 The scene described by Figure 2 to Figure 6 The method of training a decision tree for identifying waybill types in the disclosed embodiment is described in detail.
[0101] Figure 2 The flowchart of the method for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown.
[0102] like Figure 2 As shown, the training method of this embodiment includes operations S210 to S250.
[0103] In operation S210, a target training sample set is generated according to a plurality of waybill flag data, wherein each waybill flag data includes data corresponding to a plurality of feature bits, respectively, and the feature bits are used to identify the waybill type;
[0104] In operation S220, the target training sample set is assigned to a root node in the decision tree;
[0105] In operation S230, a target segmentation feature is assigned to a subnode to which a segmentation feature is to be assigned in the decision tree using a preset algorithm, wherein the target segmentation feature is used to segment the waybill flag bit data in the subnode to which the segmentation feature is to be assigned based on the data corresponding to the target feature bit;
[0106] In operation S240, based on the target segmentation feature, the waybill flag data in the child node to be assigned the segmentation feature is segmented to obtain the waybill flag data corresponding to the next child node to be assigned the segmentation feature;
[0107] In operation S250, the preset algorithm is iteratively executed to assign the next target segmentation feature to the child node of the next segmentation feature to be assigned, and based on the next target segmentation feature, the waybill flag data in the child node of the next segmentation feature to be assigned is segmented until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
[0108] According to an embodiment of the present disclosure, the waybill flag data is a random number in the logistics waybill number, which is composed of numbers and letters, for example: 13567AB; each waybill contains a waybill flag data, and the waybill flag data can be used to characterize the waybill type. By identifying a certain waybill flag data, the waybill type of the waybill can be obtained. The waybill flag data can be exported from the waybill database. In logistics management, waybills are divided into multiple waybill types, such as express waybills, express waybills, large-piece waybills, cold chain waybills, air waybills, water transport waybills, etc.
[0109] According to an embodiment of the present disclosure, a target training sample set is generated based on multiple waybill flag data. For example, the target training sample set can be obtained by performing data preprocessing on the multiple waybill flag data. The data preprocessing method can be, for example, filtering out dirty data, filling missing data, discretizing the data, etc. through data cleaning.
[0110] According to the embodiments of the present disclosure, each waybill flag data includes data corresponding to multiple feature bits, for example, the waybill flag data 13567AB includes 7 feature bits, and the data corresponding to the 7 feature bits are: the first feature bit corresponds to "1", the second feature bit corresponds to "3", the third feature bit corresponds to "5", the fourth feature bit corresponds to "6", the fifth feature bit corresponds to "7", the sixth feature bit corresponds to "A", and the seventh feature bit corresponds to "B". Among them, the feature bit is used to identify the waybill type, representing the possibility that the waybill belongs to a certain type of waybill. For example, the fourth feature bit corresponds to "6", which means that the waybill type may be express delivery; for example, the fourth feature bit corresponds to "5", which means that the waybill type may be express delivery, etc. The determination of the waybill type can be determined by the data of multiple feature bits in the waybill flag data. The decision tree of the embodiment of the present disclosure can finally determine the waybill type through the layer-by-layer identification of multiple feature bits.
[0111] According to an embodiment of the present disclosure, after the target training sample set is assigned to the root node in the decision tree, the root node is segmented to obtain the child nodes of the next layer, and the child nodes of the next layer are segmented again... until the termination condition is reached, a trained decision tree is obtained. The process of training the decision tree is to iteratively perform the operation of assigning target segmentation features to each child node using a preset algorithm, and segmenting the waybill flag data in each child node based on the target segmentation features.
[0112] The above operation is, for example: segmenting multiple waybill flag data contained in the root node. The decision conditions for segmenting the root node can be determined by a preset algorithm, that is, determining the target segmentation feature. For example, the target segmentation feature can be: if the third digit is equal to 5, then the waybill flag data with the third digit equal to 5 will be divided into one of the child nodes of the next layer, and the feature with the third digit not equal to 5 will be divided into another child node of the next layer. In this way, the segmentation operation of the root node is completed.
[0113] According to an embodiment of the present disclosure, the preset algorithm may be various algorithms applicable to the waybill type identification scenario, for example, it may be an ID3 decision tree algorithm.
[0114] According to an embodiment of the present disclosure, a constructed decision tree can be used to classify the waybill flag data to be identified, and the data in each leaf node belongs to the same waybill type.
[0115] According to the embodiments of the present disclosure, in the above training method, the target segmentation feature is used to segment the waybill flag bit data in the subnode to which the segmentation feature is to be assigned based on the data corresponding to the target feature bit. By determining the target segmentation feature to train the decision tree, a decision tree suitable for the waybill identification application scenario of the embodiment of the present disclosure can be constructed, and when the trained decision tree is used to identify the waybill type later, it can be accurate to use a certain bit in the waybill flag bit data to classify the waybill layer by layer, thereby improving the recognition accuracy, and realizing automatic recognition of the waybill type, improving the recognition efficiency, and avoiding the problems of low recognition efficiency of manual recognition methods, difficulty in recognition when there are many feature bits of the waybill flag data, and easy recognition errors. In addition, compared with the manual decision tree, the decision tree model trained by the preset algorithm has a lightweight structure, no redundant nodes, faster recognition speed of the computer processor, and is not easy to overfit. At the same time, the training speed is also faster, which reduces the requirements for computer equipment hardware, has strong practicality, and provides technical support for the recognition of waybill types in the logistics system.
[0116] According to an embodiment of the present disclosure, in the above method, the preset algorithm for determining the target segmentation feature may be an ID3 algorithm. Further, using the preset algorithm (ID3 algorithm) to assign the target segmentation feature to the sub-nodes to be assigned the segmentation feature in the decision tree includes:
[0117] Processing the waybill flag bit data contained in the child node to which the segmentation feature is to be assigned, so as to obtain the Gini value corresponding to each feature bit associated with the child node to which the segmentation feature is to be assigned;
[0118] The data corresponding to the feature bit whose Gini value meets the preset numerical discrimination condition is determined as the target segmentation feature.
[0119] According to an embodiment of the present disclosure, the above method traverses each waybill flag bit data contained in the child node to be executed through the ID3 algorithm to obtain the Gini value corresponding to each feature bit associated with the child node. For example, it can be calculated through the ID3 algorithm: the Gini value corresponding to decision condition 1 (the first feature bit is equal to 1) is 0.5, the Gini value corresponding to decision condition 2 (the second feature bit is equal to 3) is 0.03, and the Gini value corresponding to decision condition 3 (the fourth feature bit is equal to 3) is 0.047…, and then the Gini value that meets the preset numerical judgment condition, such as the decision condition with the smallest Gini value, is used as the separation decision condition, that is, the data corresponding to the feature bit finally selected is determined as the target segmentation feature.
[0120] According to the embodiments of the present disclosure, the ID3 algorithm selects the current best feature to segment the data according to the maximum information entropy gain, and segments the data according to all values of the feature. In the process of establishing a decision tree, the data is divided according to feature attributes, so that the entropy (degree of chaos) of the originally chaotic data is reduced. The implementation process is simple and data segmentation can be achieved quickly. In the scenario of the embodiments of the present disclosure, the waybill flag data has many features and poor regularity. By using the ID3 algorithm, the training speed can be improved while meeting the usage accuracy.
[0121] According to the embodiments of the present disclosure, in order to improve the training speed, the decision tree model can be implemented in parallel under the MapReduce framework. Specifically, under the MapReduce framework, the MapReduce execution node (parallel processing node) is used to perform in parallel: the waybill flag bit data contained in the sub-node to be assigned the segmentation feature is processed to obtain the Gini value corresponding to each feature bit associated with the sub-node to be assigned the segmentation feature.
[0122] The MapReduce execution nodes (parallel processing nodes) include statistical nodes (Reduce-side execution nodes) and multiple computing nodes (Map-side execution nodes).
[0123] Among them, a single computing node (Map-side execution node) is used to: determine the waybill types contained in the waybill flag data assigned to the single computing node, and the number of each waybill type; the statistical node (Reduce-side execution node) is used to: summarize the calculation results of multiple computing nodes to obtain the number of each waybill type associated with the sub-node of the segmentation feature to be assigned, and according to the number of each waybill type associated with the sub-node of the segmentation feature to be assigned, calculate the Gini value corresponding to each feature bit associated with the sub-node of the segmentation feature to be assigned.
[0124] Figure 3 The diagram schematically shows a schematic diagram of using MapReduce to perform statistics on data according to an embodiment of the present disclosure.
[0125] like Figure 3 As shown, the embodiment of the present disclosure distributes the data to be counted to different servers for statistics, and finally summarizes the counted data.
[0126] Specifically, during the statistics process, Reduce will receive the output of each map end.<key,value> Yes. Data with the same key will be divided into the same Reduce. In the Reduce module, the input <attribute value, category value> will be statistically calculated to form the output <attribute value, category value> required for calculating information gain. The overall information entropy, attribute information entropy and split information amount will be calculated to generate a decision tree.
[0127] In the application scenario of the embodiment of the present disclosure, the above operation may be that each map end processes the waybill flag data in the map end by using the ID3 algorithm, and outputs <waybill type, waybill quantity>, that is, the waybill types contained in the map end, and the quantity of each waybill type. Reduce will receive the data output by each map end, and the data with the same waybill type will be divided into the same Reduce. Reduce summarizes the calculation results of multiple map ends to obtain the identification summary results of multiple waybill flag data associated with the child node to be executed: <waybill type, waybill quantity>, that is, the number of waybills under each waybill type (the number of waybills is an intermediate parameter for calculating the Gini value), and then uses the obtained number of waybills, according to the calculation logic of calculating the Gini value in the ID3 algorithm, to obtain the Gini value corresponding to each feature bit associated with the child node (that is, the probability of randomly selecting two samples under each feature bit and their categories being inconsistent).
[0128] According to the embodiments of the present disclosure, since the more complicated process in the decision tree algorithm is to count the data attribute values and the number of attribute value categories, the embodiments of the present disclosure can greatly improve the speed of statistics and the speed of decision tree training through the parallel processing of MapReduce.
[0129] According to an embodiment of the present disclosure, the method further includes: pruning the trained decision tree to obtain a target decision tree. By pruning the decision tree, overfitting can be prevented.
[0130] According to an embodiment of the present disclosure, in order to increase the speed of pruning, the pruning process may be implemented in parallel under the MapReduce framework.
[0131] Specifically, firstly, under the MapReduce framework, the MapReduce execution nodes (parallel processing nodes) are used for parallel execution: the recognition result of each leaf node on the waybill flag data in the trained decision tree is determined.
[0132] The MapReduce execution nodes (parallel processing nodes) include statistical nodes (Reduce-side execution nodes) and multiple computing nodes (Map-side execution nodes).
[0133] Among them, a single computing node (Map-side execution node) is used to: parallelly calculate the recognition results of each leaf node assigned to the single computing node, and the statistical node (Reduce-side execution node) is used to summarize the recognition results of the same leaf node to obtain the recognition results of the waybill flag data of each leaf node in the trained decision tree;
[0134] Afterwards, the recognition error rate of each leaf node is determined according to the recognition result of each leaf node on the waybill flag data and the actual waybill type of the waybill flag data associated with each leaf node;
[0135] Finally, the leaf nodes whose recognition error rate is greater than the preset error rate threshold are removed to obtain the target decision tree.
[0136] In the above process, the specific processing logic of pruning using MapReduce is as follows:
[0137] First, the data will be cut and distributed using Hadoop's distribution model and sent to each server, while the initially established decision tree structure will be transferred to each host. The above operations separate the data set so that the data is distributed independently.
[0138] Then, multiple maps are used to calculate the recognition results (waybill categories) of each leaf node assigned to each map, and the map output is formed<key,value> Yes, on each map, the decision tree is used to make a data decision for each sample value, and the following output is formed based on whether the prediction is correct<key,value> For: <decision tree node number, category 1> or <decision tree node number, category 2>... The key value is the tree node number to be judged, and the value value is the recognition result.
[0139] Afterwards, the Reduce module receives the output of the map end, and the data with the same key value will be mapped to the same Reduce module. According to the same key, if the node is an incorrect input, the number of recognition failures of this node number will be increased by 1, and the total number of samples will be increased by 1. Otherwise, only the total number of this node will be increased by 1. In this way, the recognition error rate of each leaf node can be counted in the Reduce module.
[0140] Finally, according to the final output file, a pessimistic estimate is made for the error rate of the node, and this result will determine whether to prune the decision tree. According to the embodiment of the present disclosure, since the statistical operation with a large amount of calculation has been completed, when the number of nodes in the decision tree is not particularly large, the work of calculating the error rate can also be completed by a single machine.
[0141] According to the embodiments of the present disclosure, during the decision tree pruning process, the statistics of the recognition results require relatively large amounts of computation. By combining the parallel processing of MapReduce, the statistical work with large amounts of computation can be completed in parallel by MapReduce, which can improve the processing speed.
[0142] According to an embodiment of the present disclosure, in the above-mentioned training method, a target training sample set is generated based on multiple waybill flag data. For example, the target training sample set can be obtained by performing data preprocessing on the multiple waybill flag data. The data preprocessing method can, for example, include filtering out dirty data through data cleaning, filling in missing data, discretizing the data, and the like.
[0143] Specifically, the discretization operation on the data may be, for example, binary discretization processing on a plurality of waybill flag data to obtain two training sample subsets; and then determining a target training sample set from the two training sample subsets.
[0144] According to an embodiment of the present disclosure, the above discretization processing of the plurality of waybill flag data to obtain two training sample subsets may specifically include:
[0145] First, the multiple waybill flag data obtained from the database are cleaned to filter out dirty data. For example, it can be determined whether the attribute of each data is a continuous attribute. Specifically, because the waybill flag data only includes numbers and / or letters, it can be determined whether each character of the attribute of each column of the data set belongs to numbers and letters. If each character belongs to this range, it can be determined that the data attribute is a continuous attribute.
[0146] After that, the multiple waybill flag data are sorted to obtain a sample sequence; that is, all values of the continuous data attributes are sorted into a sequence in ascending order, and the sample sequence is sorted by quick sort (time complexity is ), forming a sequence S{S 1 , S 2 , ..., S n}. Where n is the number of consecutive values. Each data S in the sample sequence S i Represents one of the waybill flag data, and the sample sequence S may be a sequence formed by sorting multiple waybill flag data in ascending or descending order.
[0147] Then, multiple initial breakpoints of the sample sequence are determined, for example, breakpoint s is formed according to the S sequence, where s=S i +S i +1 (1≤i≤n-1), n sample data form n-1 breakpoint intervals s.
[0148] Then, the target breakpoint is determined according to the multiple initial breakpoints; specifically, each breakpoint s can be divided into two subsets, and the information gain rate GainRatio is calculated using them as the attribute division standard, and the breakpoint s when the gain rate takes the maximum value is obtained as the target breakpoint.
[0149] Finally, the sample sequence is split into two according to the target breakpoint to obtain two training sample subsets, that is, the sequence S is split into two according to the maximum gain rate breakpoint among multiple breakpoints s, completing the binary discretization of the original data.
[0150] According to an embodiment of the present disclosure, after binary discretization of multiple waybill flag data to obtain two training sample subsets, a target training sample set is determined from the two training sample subsets. For example, a part of the two training sample subsets (for example, one quarter) are respectively combined as the target training sample set, and the remaining parts of the two training sample subsets (for example, three quarters) are combined as the test sample set.
[0151] According to the embodiments of the present disclosure, by discretizing the waybill flag data, the data features can be discretized and dispersed, the availability of training samples can be improved, and the decision tree can be trained with the processed data to improve the accuracy of the decision tree prediction.
[0152] According to an embodiment of the present disclosure, in the above operation, multiple initial breakpoints of the sample sequence are determined, and the determination of multiple breakpoint intervals s can also be implemented in parallel under the MapReduce framework, that is, the operation of determining multiple initial breakpoints of the sample sequence is performed in parallel using MapReduce execution nodes (parallel processing nodes).
[0153] The MapReduce execution node (parallel processing node) includes a statistical node (Reduce-side execution node) and multiple computing nodes (Map-side execution nodes). The specific execution process can refer to the description of using MapReduce to implement decision tree training and using MapReduc to implement decision tree pruning in the embodiments of the present disclosure, which will not be repeated here.
[0154] Figure 4 The flowchart of the method for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown.
[0155] like Figure 4 As shown, the training method of this embodiment includes operations S410 to S450.
[0156] In operation S410, a plurality of waybill flag data in the waybill system is exported from the waybill database.
[0157] In operation S420, MapReduce is used to perform binary separation processing on the above-mentioned multiple waybill flag data to obtain two training sample subsets; then a target training sample set and a test sample set are determined from the two training sample subsets. The specific execution process can refer to the description of generating a target training sample set based on multiple waybill flag data and performing binary separation processing on multiple waybill flag data in the above-mentioned embodiment of the present disclosure, which will not be repeated here.
[0158] In operation S430, MapReduce is used to train a decision tree with the target training sample set to construct a decision tree model. For specific operations, reference may be made to the description of the training decision tree and the parallel execution of MapReduce in the above-mentioned embodiment of the present disclosure for processing the waybill flag bit data contained in the subnode to which the segmentation feature is to be assigned to obtain the Gini value corresponding to each feature bit associated with the subnode to which the segmentation feature is to be assigned, which will not be repeated here.
[0159] In operation S440, MapReduce is used to prune the constructed decision tree. For specific operations, reference may be made to the description of the parallel implementation of the pruning operation under the MapReduce framework in the above-mentioned embodiment of the present disclosure, which will not be repeated here.
[0160] In operation S450, the trained decision tree is tested and verified using a test sample set to verify its accuracy in data recognition and classification.
[0161] The above-mentioned embodiment of the present disclosure provides a method for training a decision tree for identifying waybill types based on parallel processing. The method uses Java to write MapReduce to train the ID3 decision tree, providing technical support for identifying waybill types in the logistics system.
[0162] The present disclosure also provides a method for identifying waybill types by applying a decision tree, comprising:
[0163] Get the waybill flag data to be identified;
[0164] Inputting the waybill flag data to be identified into the decision tree obtained by the above training method of the embodiment of the present disclosure;
[0165] Use the decision tree to output the waybill type of the waybill flag data to be identified.
[0166] According to the embodiments of the present disclosure, by using the decision tree trained by the above method to identify the type of waybill, it is possible to accurately use a certain bit in the waybill flag data to classify the waybill layer by layer, thereby improving the recognition accuracy, and realizing automatic recognition of the waybill type, improving the recognition efficiency, and avoiding the problems of low recognition efficiency of manual recognition methods, difficulty in recognition when the waybill flag has a large number of data feature bits, and easy recognition errors.
[0167] Based on the above training method, the present disclosure also provides a device for training a decision tree for identifying waybill types.
[0168] Figure 5 The following schematically shows a structural block diagram of a device for training a decision tree for identifying the type of waybill according to an embodiment of the present disclosure. Figure 5 The device is described in detail.
[0169] like Figure 5 As shown, the device 500 includes a generation module 510 , a first allocation module 520 , a second allocation module 530 , a segmentation module 540 and an iteration module 550 .
[0170] The generating module 510 is used to generate a target training sample set according to a plurality of waybill flag data, wherein each waybill flag data includes data corresponding to a plurality of feature bits, and the feature bits are used to identify the waybill type;
[0171] A first allocation module 520, configured to allocate a target training sample set to a root node in a decision tree;
[0172] The second allocation module 530 is used to allocate the target segmentation feature to the sub-node to be allocated the segmentation feature in the decision tree using a preset algorithm, wherein the target segmentation feature is used to segment the waybill flag bit data in the sub-node to be allocated the segmentation feature based on the data corresponding to the target feature bit;
[0173] The segmentation module 540 is used to segment the waybill flag data in the subnode to be assigned the segmentation feature based on the target segmentation feature, so as to obtain the waybill flag data corresponding to the next subnode to be assigned the segmentation feature;
[0174] Iteration module 550 is used to iteratively execute the preset algorithm to assign the next target segmentation feature to the child node of the next segmentation feature to be assigned, and based on the next target segmentation feature, segment the waybill flag data in the child node of the next segmentation feature to be assigned, until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
[0175] According to the embodiment of the present disclosure, in the above-mentioned training device, the target segmentation feature determined by the second allocation module 530 is used to segment the waybill flag bit data in the subnode to which the segmentation feature is to be assigned based on the data corresponding to the target feature bit. The target segmentation feature is determined by the second allocation module 530 to train the decision tree, and a decision tree suitable for the waybill identification application scenario of the embodiment of the present disclosure can be constructed. When the trained decision tree is subsequently used to identify the waybill type, it can be accurate to use a certain bit in the waybill flag bit data to classify the waybill layer by layer, thereby improving the recognition accuracy, and realizing automatic recognition of the waybill type, improving the recognition efficiency, and avoiding the problems of low recognition efficiency of manual recognition methods, difficulty in recognition when there are many feature bits of the waybill flag data, and easy recognition errors. In addition, the decision tree constructed by the device is lighter in structure than the manual decision tree, does not have redundant nodes, has a faster recognition speed, is not easy to overfit, and has a faster training speed. It has strong practicality and provides technical support for the recognition of waybill types in the logistics system.
[0176] According to an embodiment of the present disclosure, the second allocation module includes a first processing unit and a first determining unit.
[0177] The first processing unit is used to process the waybill flag bit data contained in the sub-node to which the segmentation feature is to be assigned using a preset algorithm to obtain a Gini value corresponding to each feature bit associated with the sub-node to which the segmentation feature is to be assigned;
[0178] The first determining unit is used to determine data corresponding to a feature bit whose Gini value meets a preset numerical discrimination condition as a target segmentation feature.
[0179] According to an embodiment of the present disclosure, the first processing unit includes a first execution subunit.
[0180] The first execution subunit is used to perform in parallel using parallel processing nodes: processing the waybill flag bit data contained in the subnode to which the segmentation feature is to be assigned to obtain the Gini value corresponding to each feature bit associated with the subnode to which the segmentation feature is to be assigned, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein
[0181] A single computing node is used to: determine the waybill types contained in the waybill flag data assigned to the single computing node, and the quantity of each waybill type;
[0182] The statistical node is used to: summarize the calculation results of multiple calculation nodes to obtain the number of each waybill type associated with the sub-node of the segmentation feature to be assigned, and calculate the Gini value corresponding to each feature bit associated with the sub-node of the segmentation feature to be assigned based on the number of each waybill type associated with the sub-node of the segmentation feature to be assigned.
[0183] According to an embodiment of the present disclosure, the above-mentioned device also includes a pruning module, which is used to prune the trained decision tree to obtain a target decision tree.
[0184] According to an embodiment of the present disclosure, the pruning module includes an execution unit, a second determination unit and a removal unit.
[0185] Wherein, the execution unit is used to perform in parallel using the parallel processing nodes: determining the recognition result of each leaf node for the waybill flag data in the trained decision tree, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein a single computing node is used to parallelly calculate the recognition result of each leaf node assigned to the single computing node, and the statistical node is used to summarize the recognition results of the same leaf node to obtain the recognition result of each leaf node for the waybill flag data in the trained decision tree;
[0186] A second determination unit is used to determine the recognition error rate of each leaf node according to the recognition result of each leaf node on the waybill flag data and the actual waybill type of the waybill flag data associated with each leaf node;
[0187] The removal unit is used to remove leaf nodes whose recognition error rate is greater than a preset error rate threshold to obtain a target decision tree.
[0188] According to an embodiment of the present disclosure, the generating module includes a second processing unit and a third determining unit.
[0189] The second processing unit is used to discretize the multiple waybill flag data to obtain two training sample subsets;
[0190] The third determining unit is used to determine a target training sample set from the two training sample subsets.
[0191] According to an embodiment of the present disclosure, the second processing unit includes a sorting subunit, a second executing subunit, a determining subunit, and a segmenting subunit.
[0192] The sorting subunit is used to sort the multiple waybill flag data to obtain a sample sequence;
[0193] A second execution subunit, configured to use parallel processing nodes to perform operations of determining multiple initial breakpoints of a sample sequence in parallel;
[0194] A determination subunit, used for determining a target breakpoint according to a plurality of initial breakpoints;
[0195] The segmentation subunit is used to split the sample sequence into two according to the target breakpoint to obtain two training sample subsets.
[0196] The present disclosure also provides a device for identifying waybill types using a decision tree, comprising an acquisition module, an input module and an output module.
[0197] The acquisition module is used to obtain the waybill flag data to be identified;
[0198] An input module, used for inputting the waybill flag data to be identified into the decision tree trained by the above training method;
[0199] The output module is used to output the waybill type of the waybill flag data to be identified by using the decision tree.
[0200] According to the embodiments of the present disclosure, by utilizing the above-mentioned device to identify waybills, it is possible to accurately utilize a certain bit in the waybill flag data to implement hierarchical classification of waybills, thereby improving recognition accuracy, and realizing automatic recognition of waybill types, improving recognition efficiency, and avoiding the problems of low recognition efficiency of manual recognition methods, difficulty in recognition when the waybill flag has a large number of data feature bits, and easy recognition errors.
[0201] According to an embodiment of the present disclosure, any multiple modules among the generation module 510, the first allocation module 520, the second allocation module 530, the segmentation module 540, the iteration module 550, the acquisition module, the input module, and the output module can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the generation module 510, the first allocation module 520, the second allocation module 530, the segmentation module 540, the iteration module 550, the acquisition module, the input module, and the output module can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware, and firmware or in an appropriate combination of any of them. Alternatively, at least one of the generation module 510, the first allocation module 520, the second allocation module 530, the segmentation module 540, the iteration module 550, the acquisition module, the input module, and the output module can be at least partially implemented as a computer program module, which can perform corresponding functions when the computer program module is executed.
[0202] Figure 6 A block diagram of an electronic device suitable for implementing a method for training a decision tree for identifying waybill types according to an embodiment of the present disclosure is schematically shown.
[0203] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0204] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0205] According to an embodiment of the present disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the I / O interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.
[0206] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0207] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 602 and / or RAM 603 described above and / or one or more memories other than ROM 602 and RAM 603.
[0208] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the training method provided by the embodiment of the present disclosure.
[0209] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 601. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0210] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0211] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, apparatus, module, unit, etc. described above can be implemented by a computer program module.
[0212] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0213] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0214] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0215] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for training a decision tree for identifying a waybill type, comprising: Generate a target training sample set according to a plurality of waybill flag data, wherein each waybill flag data includes data corresponding to a plurality of feature bits, and the feature bits are used to identify the waybill type; Assigning the target training sample set to a root node in a decision tree; Using a preset algorithm to assign a target segmentation feature to a subnode of the decision tree to which the segmentation feature is to be assigned, wherein the target segmentation feature is used to segment the waybill flag bit data in the subnode of the decision tree to which the segmentation feature is to be assigned based on the data corresponding to the target feature bit; Based on the target segmentation feature, segment the waybill flag data in the child node of the to-be-assigned segmentation feature to obtain the waybill flag data corresponding to the next child node of the to-be-assigned segmentation feature; Iterative execution uses the preset algorithm to assign the next target segmentation feature to the child node of the next segmentation feature to be assigned, and based on the next target segmentation feature, the waybill flag data in the child node of the next segmentation feature to be assigned is segmented until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
2. The method according to claim 1, wherein: The step of using a preset algorithm to assign a target segmentation feature to a sub-node to be assigned a segmentation feature in the decision tree comprises: Using the preset algorithm, the waybill flag bit data contained in the subnode of the to-be-assigned segmentation feature is processed to obtain a Gini value corresponding to each feature bit associated with the subnode of the to-be-assigned segmentation feature; The data corresponding to the feature bit whose Gini value meets the preset numerical discrimination condition is determined as the target segmentation feature.
3. The method according to claim 2, wherein: The processing of the waybill flag bit data contained in the subnode of the to-be-allocated segmentation feature to obtain the Gini value corresponding to each feature bit associated with the subnode of the to-be-allocated segmentation feature includes: The parallel processing nodes are used to perform in parallel: the operation of processing the waybill flag bit data contained in the sub-node of the to-be-assigned segmentation feature to obtain the Gini value corresponding to each feature bit associated with the sub-node of the to-be-assigned segmentation feature, wherein the parallel processing nodes include a statistical node and a plurality of computing nodes, wherein A single computing node is used to: determine the waybill type contained in the waybill flag data assigned to the single computing node, and the quantity of each waybill type; The statistical node is used to: summarize the calculation results of multiple calculation nodes to obtain the number of each waybill type associated with the sub-node of the segmentation feature to be assigned, and calculate the Gini value corresponding to each feature bit associated with the sub-node of the segmentation feature to be assigned based on the number of each waybill type associated with the sub-node of the segmentation feature to be assigned.
4. The method according to claim 1, further comprising: The trained decision tree is pruned to obtain a target decision tree.
5. The method according to claim 4, wherein: The step of pruning the trained decision tree to obtain a target decision tree includes: Execute in parallel using parallel processing nodes: determine the recognition result of each leaf node for the waybill flag data in the trained decision tree, wherein the parallel processing node includes a statistical node and a plurality of computing nodes, wherein a single computing node is used to parallelly calculate the recognition result of each leaf node assigned to the single computing node, and the statistical node is used to summarize the recognition results of the same leaf node to obtain the recognition result of each leaf node for the waybill flag data in the trained decision tree; Determine the recognition error rate of each leaf node according to the recognition result of each leaf node on the waybill flag data and the actual waybill type of the waybill flag data associated with each leaf node; The leaf nodes whose recognition error rate is greater than a preset error rate threshold are removed to obtain the target decision tree.
6. The method according to claim 1, wherein: Generating a target training sample set according to a plurality of waybill flag data includes: Discretize the plurality of waybill flag data to obtain two training sample subsets; The target training sample set is determined from the two training sample subsets.
7. The method according to claim 6, wherein: The discretization processing of the plurality of waybill flag data to obtain two training sample subsets includes: Sorting the plurality of waybill flag data to obtain a sample sequence; Using parallel processing nodes to perform in parallel the operation of determining a plurality of initial breakpoints of the sample sequence; determining a target breakpoint according to the multiple initial breakpoints; The sample sequence is divided into two according to the target breakpoint to obtain the two training sample subsets.
8. A method for identifying waybill types using a decision tree, comprising: Get the waybill flag data to be identified; Inputting the waybill flag data to be identified into a decision tree trained by the method according to any one of claims 1 to 7; The decision tree is used to output the waybill type of the waybill flag data to be identified.
9. A device for training a decision tree for identifying a waybill type, comprising: A generating module, used to generate a target training sample set according to a plurality of waybill flag data, wherein each waybill flag data includes data corresponding to a plurality of feature bits, and the feature bits are used to identify the waybill type; A first allocation module, used to allocate the target training sample set to a root node in a decision tree; A second allocation module is used to allocate a target segmentation feature to the sub-node of the segmentation feature to be allocated in the decision tree using a preset algorithm, wherein the target segmentation feature is used to segment the waybill flag bit data in the sub-node of the segmentation feature to be allocated based on the data corresponding to the target feature bit; A segmentation module, configured to segment the waybill flag data in the subnode of the to-be-allocated segmentation feature based on the target segmentation feature, so as to obtain the waybill flag data corresponding to the next subnode of the to-be-allocated segmentation feature; An iteration module is used to iteratively execute the preset algorithm to assign the next target segmentation feature to the subnode of the next segmentation feature to be assigned, and based on the next target segmentation feature, segment the waybill flag data in the subnode of the next segmentation feature to be assigned, until the preset segmentation termination condition is met, thereby obtaining a trained decision tree.
10. A device for identifying waybill types using a decision tree, comprising: An acquisition module is used to obtain the waybill flag data to be identified; An input module, used for inputting the waybill flag data to be identified into a decision tree trained by the method according to any one of claims 1 to 7; An output module is used to output the waybill type of the waybill flag data to be identified using the decision tree.
11. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to execute the method according to any one of claims 1 to 7.
12. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the method according to any one of claims 1 to 7.
13. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
