Decision tree testing method and apparatus, electronic device, and storage medium

By exhaustively exploring decision tree paths and comparing the execution results with the expected results, the problem of difficulty in discovering conflicts between logical nodes when testing decision trees is solved, reducing testing costs and improving logical accuracy.

CN114817036BActive Publication Date: 2026-01-23JINGDONG TECH HLDG CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210447373.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-26
Publication Date
2026-01-23
Estimated Expiration
2042-04-26

AI Technical Summary

Technical Problem

In existing technologies, it is difficult to detect conflicts between logical nodes when testing decision trees, and the manpower and time costs are relatively high.

Method used

By obtaining multiple paths of the target decision tree, using the instance library to filter test instances, and inputting them into the decision tree to compare the execution results with the expected results, the decision tree paths are exhaustively enumerated to cover the entire process, and conflicts between logical nodes are discovered.

Benefits of technology

It effectively reduces the cost of decision tree testing, improves logical accuracy, reduces manpower and time consumption, and ensures the detection of conflicts between logical nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114817036B_ABST
    Figure CN114817036B_ABST
Patent Text Reader

Abstract

The present disclosure provides a decision tree testing method, which can be applied to the technical field of computers. The method comprises the following steps: obtaining a plurality of decision tree paths of a target decision tree, wherein each decision tree path has a leaf node, and the leaf node represents an expected result of the decision tree path; screening a plurality of test instances corresponding to the plurality of decision tree paths from an instance library; inputting the plurality of test instances into the target decision tree respectively to obtain a plurality of execution results; and comparing the plurality of expected results with the plurality of execution results to obtain a testing result of the target decision tree. In addition, the present disclosure also provides a decision tree testing device, an electronic device and a readable storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically, to a decision tree testing method, apparatus, electronic device, readable storage medium, and computer program product. Background Technology

[0002] A decision tree is a method that visually lists the steps involved in solving a problem, along with the conditions and results of each step. In related technologies, decision trees can graphically represent complex business logic, making it easier for business personnel to modify it.

[0003] In the process of realizing the present invention, the inventors found that the related technologies have at least the following problems: it is difficult to find conflicts between logical nodes when testing decision trees, and the consumption of human resources and time costs is relatively large. Summary of the Invention

[0004] In view of the above, this disclosure provides a decision tree testing method, a decision tree testing apparatus, an electronic device, a readable storage medium, and a computer program product.

[0005] One aspect of this disclosure provides a decision tree testing method, comprising: obtaining multiple decision tree paths of a target decision tree, wherein each decision tree path has a leaf node, the leaf node representing the expected result of the decision tree path; selecting multiple test instances corresponding to the multiple decision tree paths from an instance library; inputting the multiple test instances into the target decision tree respectively to obtain multiple execution results; and comparing the multiple expected results with the multiple execution results to obtain the test result of the target decision tree.

[0006] According to embodiments of this disclosure, the decision tree path further has at least one logical node, and each logical node is configured with a logical branch; wherein, the step of selecting multiple test instances corresponding to multiple decision tree paths from the instance library includes: for each decision tree path, performing keyword matching in the instance library using the field corresponding to the logical node of the decision tree path as a keyword; if a first target instance is obtained from the instance library, filtering is performed in at least one first target instance based on the logical branch of the logical node; and if a second target instance is obtained from the first target instance, selecting a preset number of instances from the second target instance as test instances corresponding to the decision tree path.

[0007] According to embodiments of this disclosure, the method further includes: if a first target instance cannot be matched from the instance library, or if a second target instance cannot be filtered from the first target instance, generating a test instance corresponding to the decision tree path based on the fields corresponding to the logical node and the logical branches of the logical node; and storing the test instance in the instance library.

[0008] According to embodiments of this disclosure, the above-mentioned inputting multiple test instances corresponding to multiple decision tree paths into the target decision tree to obtain multiple execution results includes: for each test instance, inputting the test instance into the target decision tree multiple times to obtain multiple decision results; and when multiple decision results are consistent, determining the execution result of the test instance as the decision result.

[0009] According to embodiments of this disclosure, the method further includes: when there is a decision result that is inconsistent with other decision results among the multiple decision results, returning the path information of the decision tree path corresponding to the test instance to the terminal device for manual verification.

[0010] According to embodiments of this disclosure, the method further includes: for each decision tree path, if the expected result corresponding to the decision tree path and the execution result corresponding to the decision tree path are inconsistent, returning the path information of the decision tree path to the terminal device for manual verification.

[0011] Another aspect of this disclosure provides a decision tree testing apparatus, comprising: an acquisition module for acquiring multiple decision tree paths of a target decision tree, wherein each decision tree path has a leaf node, the leaf node representing the expected result of the decision tree path; a first processing module for filtering multiple test instances corresponding to the multiple decision tree paths from an instance library; a second processing module for inputting the multiple test instances into the target decision tree respectively to obtain multiple execution results; and a comparison module for comparing the multiple expected results with the multiple execution results to obtain the test results of the target decision tree.

[0012] Another aspect of this disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more instructions, wherein when the one or more instructions are executed by the one or more processors, the one or more processors cause the one or more processors to perform the method as described above.

[0013] Another aspect of this disclosure provides a computer-readable storage medium storing computer-executable instructions that, when executed, are used to implement the method described above.

[0014] Another aspect of this disclosure provides a computer program product including computer-executable instructions that, when executed, are used to implement the method described above.

[0015] According to embodiments of this disclosure, when testing a target decision tree, all decision tree paths can be exhaustively enumerated, and test instances can be selected from an instance library based on each decision tree path. Then, the execution results of the test instances can be compared with the expected results to determine the test result of the target decision tree. Through the above technical means, the entire process of the target decision tree can be covered, at least partially overcoming the technical problems in related technologies where it is difficult to detect conflicts between logical nodes during decision tree testing, and where high manpower and time costs are incurred. This effectively reduces the testing cost of decision trees and improves the logical accuracy of decision trees. Attached Figure Description

[0016] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:

[0017] Figure 1 An exemplary system architecture for applying decision tree testing methods according to embodiments of this disclosure is illustrated schematically.

[0018] Figure 2 A flowchart illustrating a decision tree testing method according to an embodiment of the present disclosure is shown schematically.

[0019] Figure 3 A flowchart illustrating a test instance selection method according to an embodiment of the present disclosure is shown schematically.

[0020] Figure 4 A flowchart illustrating a decision tree testing method according to another embodiment of the present disclosure is shown schematically.

[0021] Figure 5 A block diagram of a decision tree testing apparatus according to an embodiment of the present disclosure is shown schematically.

[0022] Figure 6 A block diagram of an electronic device suitable for implementing a decision tree testing method according to an embodiment of the present disclosure is shown schematically. Detailed Implementation

[0023] The embodiments of the present disclosure will now 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 disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.

[0024] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0025] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0026] When using expressions such as "at least one of A, B, and C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.). Similarly, when using expressions such as "at least one of A, B, or C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, or C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).

[0027] A decision tree is a tree-like structure where each internal node represents a test on an attribute, each branch represents a test output, and each leaf node represents a category. In related technologies, enterprises often use decision trees to orchestrate business logic.

[0028] However, during the modification and orchestration of the decision tree, adding new logical nodes or modifying existing logical nodes may affect the execution results and main logic of the decision tree. To address this issue, the following solutions are commonly used in related technologies to test the decision tree: (1) After adding or modifying nodes, test the node functions and execution results; (2) Orchestrate the new nodes into the existing process and test the execution results of the main process; (3) After orchestrating the process around the new nodes, test the execution results of the main process; (4) For an already orchestrated decision tree, test the execution results when adding or modifying nodes.

[0029] The solutions of related technologies have the following problems: (1) When adding a new logical node, the logic of the node can only be tested by the R&D personnel, the node can be arranged into the existing decision tree process, and the result of the decision tree execution can be returned. This is more likely to cause hidden logical problems. (2) When modifying the logic of an existing node, it is necessary to return to the entire decision tree process that depends on the node. As the number of arranged processes increases, the difficulty and complexity of the return increases significantly. If only the process of a few decision trees is tested and returned, it is not possible to cover the entire process and is not rigorous enough. (3) After adding or modifying nodes in the arranged decision tree process, the time and manpower costs required for developers to cover the entire logic when testing the process are large. As the number of logical nodes increases, there are conflicts between the logic of some nodes. It is difficult to find these hidden conflicts when the process is arranged.

[0030] In view of this, embodiments of the present disclosure provide a method for testing decision trees, which predicts the decision tree path by exhaustively exploring the decision tree nodes, and uses this as a standard for analyzing logic.

[0031] Specifically, embodiments of this disclosure provide a decision tree testing method, apparatus, electronic device, readable storage medium, and computer program product. The method includes: obtaining multiple decision tree paths of a target decision tree, wherein each decision tree path has leaf nodes, and the leaf nodes represent the expected results of the decision tree path; selecting multiple test instances corresponding to the multiple decision tree paths from an instance library; inputting the multiple test instances into the target decision tree respectively to obtain multiple execution results; and comparing the multiple expected results with the multiple execution results to obtain the test results of the target decision tree.

[0032] In the technical solution disclosed herein, the acquisition, storage, and application of user personal information comply with the provisions of relevant laws and regulations, necessary confidentiality measures have been taken, and there is no violation of public order and good morals.

[0033] In the technical solution disclosed herein, the user's authorization or consent is obtained before acquiring or collecting the user's personal information.

[0034] Figure 1An exemplary system architecture for applying decision tree testing methods according to embodiments of this disclosure is illustrated schematically. It should be noted that... Figure 1 The examples shown are merely examples of system architectures that can be applied to the embodiments of this disclosure, in order to help those skilled in the art understand the technical content of this disclosure, but do not mean that the embodiments of this disclosure cannot be used in other devices, systems, environments or scenarios.

[0035] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, and 103, a network 104, and a server 105.

[0036] Terminal devices 101, 102, and 103 can be various electronic devices with displays, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0037] Network 104 is a medium used to provide a communication link between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0038] Server 105 can be a server or server group that provides various services, or it can be a cloud server located in the cloud.

[0039] Various client applications can be installed on terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social media platforms. Users can directly or indirectly arrange and modify the decision tree through these client applications. Afterward, the decision tree can be sent to server 105 via network 104, where server 105 will test the decision tree.

[0040] It should be noted that the decision tree testing method provided in this embodiment can generally be executed by server 105. Correspondingly, the decision tree testing apparatus provided in this embodiment can generally be located in server 105. The decision tree testing method provided in this embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Correspondingly, the decision tree testing apparatus provided in this embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with terminal devices 101, 102, 103 and / or server 105. Alternatively, the decision tree testing method provided in this embodiment can also be executed by terminal devices 101, 102, or 103, or by other terminal devices different from terminal devices 101, 102, or 103. Accordingly, the decision tree testing device provided in this embodiment of the present disclosure may also be set in terminal device 101, 102, or 103, or in other terminal devices different from terminal device 101, 102, or 103.

[0041] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0042] Figure 2 A flowchart illustrating a decision tree testing method according to an embodiment of the present disclosure is shown schematically.

[0043] like Figure 2 As shown, the method includes operations S201 to S204.

[0044] In operation S201, multiple decision tree paths of the target decision tree are obtained, where each decision tree path has a leaf node, and the leaf node represents the expected result of the decision tree path.

[0045] In operation S202, multiple test instances corresponding to multiple decision tree paths are selected from the instance library.

[0046] In operation S203, multiple test instances are input into the target decision tree to obtain multiple execution results.

[0047] In operation S204, multiple expected results are compared with multiple execution results to obtain the test results of the target decision tree.

[0048] According to embodiments of this disclosure, the target decision tree may include multiple logical nodes and multiple leaf nodes.

[0049] According to embodiments of this disclosure, the target decision tree can be a decision tree obtained after arrangement, or a decision tree obtained by adding, modifying or deleting logical nodes or leaf nodes in the original decision tree.

[0050] According to embodiments of this disclosure, each logical node may have multiple logical branches. For example, each logical node may include three logical branches: "yes", "no", and "abnormal".

[0051] According to embodiments of this disclosure, each leaf node can represent a category of the target decision tree output. For example, in a decision tree applied to a lottery procedure, the category of the decision tree output may include prize pool a, prize pool b, prize pool c, etc.

[0052] According to embodiments of this disclosure, a logical branch of each logical node can be connected to another logical node or leaf node. For example, the "yes" logical branch of logical node A can be connected to logical node B, indicating that if the logical relationship represented by logical node A is determined to be yes, the determination of the logical relationship represented by logical node B continues; the "no" logical branch of logical node A can be connected to leaf node C, indicating that if the logical relationship represented by logical node A is determined to be no, the category represented by leaf node C is output.

[0053] According to embodiments of this disclosure, a decision tree path can be represented as a path in the target decision tree that starts from the first logical node, proceeds along logical branches to the leaf node.

[0054] According to embodiments of this disclosure, all decision tree paths can be obtained from the target decision tree by exhaustively enumerating each logical node.

[0055] According to embodiments of this disclosure, the instance library may store multiple instances. These instances may be created during previous testing or generated by recording user information during actual use of the application corresponding to the target decision tree. For example, the application corresponding to the target decision tree may be a lottery program. When a user logs into the lottery program to participate in a lottery, the program may, with the user's consent, convert the user information into an instance and store it in the instance library.

[0056] According to embodiments of this disclosure, test instances can be selected from the instance library based on logical nodes and logical branches in the decision tree path. The number of test instances corresponding to each decision tree path can be one or more.

[0057] According to embodiments of this disclosure, inputting multiple test instances into the target decision tree can be achieved by inputting multiple test instances into an application corresponding to the target decision tree.

[0058] According to embodiments of this disclosure, for each decision tree path, the attribute represented by the leaf node of the decision tree path is the expected result corresponding to the decision tree path.

[0059] According to embodiments of this disclosure, the expected result and execution result corresponding to each decision tree path can be compared. If the comparison results of all decision tree paths are consistent, the logic of the target decision tree can be considered accurate. If the comparison results of any decision tree path are inconsistent, it can be considered that a logical error has occurred between multiple logical nodes in the decision tree path, or between a logical node and a leaf node in the decision tree path. Developers can check the logical nodes and leaf nodes involved in the decision tree path, reducing the scope of logical errors that need to be investigated and improving testing efficiency.

[0060] According to embodiments of this disclosure, when testing a target decision tree, all decision tree paths can be exhaustively enumerated, and test instances can be selected from an instance library based on each decision tree path. Then, the execution results of the test instances can be compared with the expected results to determine the test result of the target decision tree. Through the above technical means, the entire process of the target decision tree can be covered, at least partially overcoming the technical problems in related technologies where it is difficult to detect conflicts between logical nodes during decision tree testing, and where high manpower and time costs are incurred. This effectively reduces the testing cost of decision trees and improves the logical accuracy of decision trees.

[0061] The following is for reference. Figures 3-4 In conjunction with specific embodiments, Figure 2 The method shown will be further explained.

[0062] Figure 3 A flowchart illustrating a test instance selection method according to an embodiment of the present disclosure is shown schematically.

[0063] like Figure 3 As shown, the method includes operations S301 to S306.

[0064] In operation S301, keyword matching is performed in the instance library using the field corresponding to the logical node of the decision tree path as the keyword.

[0065] In operation S302, determine whether a first target instance is matched; if it is determined that a first target instance is matched, execute operation S303; if it is determined that a first target instance is not matched, execute operation S306.

[0066] In operation S303, logical branches based on logical nodes are filtered in the first target instance.

[0067] In operation S304, determine whether a second target instance has been obtained through filtering. If it is determined that a second target instance has been obtained through filtering, execute operation S305; if it is determined that a second target instance has not been obtained through filtering, execute operation S306.

[0068] In operation S305, a preset number of instances are selected from the second target instances as test instances.

[0069] In operation S306, test instances are generated based on the fields corresponding to logical nodes and the logical branches of logical nodes.

[0070] According to embodiments of this disclosure, the method of operating S301 to S306 can be used to obtain a test instance of any decision tree path of the target decision tree.

[0071] For example, one of the decision tree paths in a target decision tree could be: A is -> B is abnormal -> abnormal category. This decision tree path includes logical nodes "A" and "B" and a leaf node representing the "abnormal category".

[0072] According to embodiments of this disclosure, fields corresponding to logical nodes can be determined. For example, logical node "A" can correspond to the field "IsANode", and logical node "B" can correspond to the field "IsBNode".

[0073] According to an embodiment of this disclosure, when performing the method of operation S301, “IsANode” and “IsBNode” can be used as keywords to search for instances containing the above two keywords in the instance library as first target instances. The number of first target instances obtained by the search can be zero or one or more.

[0074] According to embodiments of this disclosure, in addition to the keywords "IsANode" and "IsBNode", the first target instance may also contain other keywords, such as "IsCNode". Assuming "IsCNode" corresponds to logical node "C", then logical node "C" can be a logical node connected to other logical branches of logical node "B". Therefore, after matching the first target instance, further filtering can be performed based on logical branches.

[0075] According to embodiments of this disclosure, the attributes of logical nodes can be determined based on logical branches. For example, in the decision tree path, if the logical branches of a logical node include "Yes", "No", and "Abnormal", then the attributes of the fields corresponding to the logical nodes include "Y", "N", and "E". Accordingly, if the logical branch of logical node "A" is "Yes", the attribute of "IsANode" can be determined to be "Y"; if the logical branch of logical node "B" is "Abnormal", the attribute of "IsBNode" can be determined to be "E".

[0076] According to an embodiment of this disclosure, when performing the method of operation S303, a second target instance can be selected from the first target instance based on the attribute "Y" of the keyword "IsANode" and the attribute "E" of the keyword "IsBNode". The number of the selected second target instances can be zero or one or more.

[0077] According to embodiments of this disclosure, the second target instance can be as shown in Table 1. Wherein, “pin”: “123456” indicates that the identifier of the instance is “123456”. In the case where the instance is obtained by converting user information, the identifier of the instance can be the user's ID; “IsANode”: “Y” indicates that the logical branch of the instance corresponding to logical node “A” is “Y”; “IsBNode”: “E” indicates that the logical branch of the instance corresponding to logical node “B” is “E”.

[0078] Table 1

[0079]

[0080] According to embodiments of this disclosure, the preset quantity can be set to 1, or it can be set to any integer greater than 1 depending on the specific application scenario, without limitation.

[0081] According to embodiments of this disclosure, the process of generating a test instance may involve converting each logical node and its logical branch in the decision tree path into fields as shown in Table 1, filling all fields into a preset structure template, and then generating a string of characters as the identifier of the instance, thereby completing the generation of the test instance.

[0082] According to embodiments of this disclosure, the generated test instance can be stored in an instance library so that it can be directly called during the next test, thereby improving testing efficiency.

[0083] Figure 4 A flowchart illustrating a decision tree testing method according to another embodiment of the present disclosure is shown schematically.

[0084] like Figure 4 As shown, the method includes operations S401 to S409, wherein operations S401 to S404 can be executed by the backend server, and operations S405 to S409 can be executed by the frontend device or by the backend server.

[0085] It should be noted that, unless it is explicitly stated that there is a sequential order of execution between different operations, or that there is a sequential order of execution between different operations in terms of technical implementation, the execution order between multiple operations may not be significant, and multiple operations may be executed simultaneously.

[0086] When operating S401, call the instance library to obtain a test instance that meets the conditions.

[0087] In operation S402, exhaust all logical nodes and pass in the test instance.

[0088] In operation S403, record all decision tree paths obtained after exhausting all logical nodes.

[0089] When operating S404, the expected result is output.

[0090] In S405 operation, the acquired test instance is reused.

[0091] When operating S406, batch call the test application and pass in the test instance.

[0092] When operating S407, the decision result is output.

[0093] When operating S408, the decision results obtained from multiple calls to the test application are compared to determine the execution result.

[0094] In operation S409, the expected result is compared with the execution result.

[0095] According to the embodiments of this disclosure, the methods for operating S401 to S407 can be implemented based on the methods for operating S201 to S204 and the methods for operating S301 to S306, which will not be described in detail here.

[0096] According to embodiments of this disclosure, the test application may be an application corresponding to the target decision tree.

[0097] According to embodiments of this disclosure, during each invocation of the test application, all test instances can be input into the test application to obtain the decision results of the test instance during this invocation.

[0098] According to embodiments of this disclosure, before comparing the expected result with the execution result, the decision results output by the same test instance during multiple calls to the test application can be compared. If the multiple decision results are consistent, the execution result of the test instance can be determined as the decision result. This method reduces the impact of random errors generated during the execution of the test application on the test results, improving the robustness of the decision tree testing process.

[0099] According to embodiments of this disclosure, if there is a decision result that is inconsistent with other decision results among multiple decision results, it can be considered that there is a logical error in the decision tree path. In this case, the path information of the decision tree path corresponding to the test instance can be returned to the developer's terminal device so that the developer can perform manual verification.

[0100] According to embodiments of this disclosure, comparing the expected result with the execution result yields a comparison result. If the comparison results are consistent, it can be assumed that there are no logical errors in the target decision tree, and the testing process for the target decision tree can be terminated. If the comparison results are inconsistent, the decision tree path corresponding to the inconsistent comparison result can be determined first, and this decision tree path can be returned to the developer's terminal device for manual verification. After the developer makes modifications, the decision tree testing method provided in embodiments of this disclosure can be applied to the modified decision tree.

[0101] Figure 5 A block diagram of a decision tree testing apparatus according to an embodiment of the present disclosure is shown schematically.

[0102] like Figure 5 As shown, the decision tree testing device 500 includes an acquisition module 510, a first processing module 520, a second processing module 530, and a comparison module 540.

[0103] The acquisition module 510 is used to acquire multiple decision tree paths of the target decision tree, wherein each decision tree path has a leaf node, and the leaf node represents the expected result of the decision tree path.

[0104] The first processing module 520 is used to filter multiple test instances corresponding to multiple decision tree paths from the instance library.

[0105] The second processing module 530 is used to input multiple test instances into the target decision tree to obtain multiple execution results.

[0106] The comparison module 540 is used to compare multiple expected results with multiple execution results to obtain the test results of the target decision tree.

[0107] According to embodiments of this disclosure, when testing a target decision tree, all decision tree paths can be exhaustively enumerated, and test instances can be selected from an instance library based on each decision tree path. Then, the execution results of the test instances can be compared with the expected results to determine the test result of the target decision tree. Through the above technical means, the entire process of the target decision tree can be covered, at least partially overcoming the technical problems in related technologies where it is difficult to detect conflicts between logical nodes during decision tree testing, and where high manpower and time costs are incurred. This effectively reduces the testing cost of decision trees and improves the logical accuracy of decision trees.

[0108] According to embodiments of this disclosure, the first processing module 520 includes a first processing unit, a second processing unit, and a third processing unit.

[0109] The first processing unit is used to perform keyword matching in the instance library for each decision tree path, using the fields corresponding to the logical nodes of the decision tree path as keywords.

[0110] The second processing unit is used to filter at least one first target instance based on the logical branch of the logical node, provided that a first target instance is matched from the instance library.

[0111] The third processing unit is used to select a preset number of instances from the second target instance as test instances corresponding to the decision tree path, when a second target instance is obtained from the first target instance.

[0112] According to embodiments of this disclosure, the decision tree testing apparatus 500 further includes a generation module and a storage module.

[0113] The generation module is used to generate a test instance corresponding to the decision tree path based on the fields corresponding to the logical node and the logical branch of the logical node when the first target instance cannot be matched from the instance library, or when the second target instance cannot be filtered from the first target instance.

[0114] The storage module is used to store test instances into the instance library.

[0115] According to embodiments of this disclosure, the second processing module 530 includes a fourth processing unit and a fifth processing unit.

[0116] The fourth processing unit is used to input the test instance into the target decision tree multiple times for each test instance to obtain multiple decision results.

[0117] The fifth processing unit is used to determine the execution result of the test instance as the decision result when multiple decision results are consistent.

[0118] According to embodiments of this disclosure, the second processing module 530 further includes a sixth processing unit.

[0119] The sixth processing unit is used to return the path information of the decision tree path corresponding to the test instance to the terminal device when there is a decision result that is inconsistent with other decision results among multiple decision results, so as to facilitate manual verification.

[0120] According to embodiments of this disclosure, the decision tree testing apparatus 500 further includes a third processing module.

[0121] The third processing module is used to return the path information of each decision tree path to the terminal device for manual verification when the expected result and the execution result corresponding to the decision tree path are inconsistent.

[0122] Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure, or at least part of the functions of any one or more of them, can be implemented in one module. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be implemented by dividing them into multiple modules. Any one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as hardware circuitry, such as Field Programmable Gate Arrays (FPGAs), Programmable Logic Arrays (PLAs), Systems-on-Chip, Systems-on-Substrate, Systems-on-Package, Application-Specific Integrated Circuits (ASICs), or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, one or more of the modules, submodules, units, and subunits according to embodiments of the present disclosure can be at least partially implemented as computer program modules, which, when run, can perform corresponding functions.

[0123] For example, any plurality of the acquisition module 510, the first processing module 520, the second processing module 530, and the comparison module 540 may be combined into one module / unit / subunit, or any one of these modules / units / subunits may be split into multiple modules / units / subunits. Alternatively, at least part of the functionality of one or more of these modules / units / subunits may be combined with at least part of the functionality of other modules / units / subunits and implemented in one module / unit / subunit. According to embodiments of the present disclosure, at least one of the acquisition module 510, the first processing module 520, the second processing module 530, and the comparison module 540 may be at least partially implemented as hardware circuitry, 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-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging the circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the acquisition module 510, the first processing module 520, the second processing module 530, and the comparison module 540 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.

[0124] It should be noted that the decision tree testing device part in the embodiments of this disclosure corresponds to the decision tree testing method part in the embodiments of this disclosure. For a detailed description of the decision tree testing device part, please refer to the decision tree testing method part, which will not be repeated here.

[0125] Figure 6 A block diagram of an electronic device suitable for implementing a decision tree testing method according to an embodiment of the present disclosure is shown schematically. Figure 6 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0126] like Figure 6 As shown, a computer 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 portion 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 an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include 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.

[0127] RAM 603 stores various programs and data required for the operation of electronic device 600. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 performs various operations of the method flow according to embodiments of the present disclosure by executing programs in ROM 602 and / or RAM 603. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 may also perform various operations of the method flow according to embodiments of the present disclosure by executing programs stored in said one or more memories.

[0128] According to embodiments of this disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the I / O interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, modem, etc. The communication section 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 disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.

[0129] According to embodiments of this disclosure, the method flow according to embodiments of this disclosure can be implemented as a computer software program. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for performing the methods shown in the flowchart. In such embodiments, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by processor 601, it performs the functions defined in the system of embodiments of this disclosure. According to embodiments of this disclosure, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0130] This disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of this disclosure.

[0131] According to embodiments of this disclosure, the computer-readable storage medium can be a non-volatile computer-readable storage medium. Examples include, but are not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0132] For example, according to embodiments of this 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.

[0133] Embodiments of this disclosure also include a computer program product comprising a computer program containing program code for performing the methods provided in the embodiments of this disclosure. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the decision tree testing method provided in the embodiments of this disclosure.

[0134] When the computer program is executed by the processor 601, it performs the functions defined in the system / apparatus of this disclosure embodiments. According to embodiments of this disclosure, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0135] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and / or installed from the removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.

[0136] According to embodiments of this disclosure, program code for executing the computer programs provided in embodiments of this disclosure can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can execute entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0137] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions. Those skilled in the art will understand that the features recited in the various embodiments and / or claims of this disclosure can be combined and / or combined in various ways, even if such combinations or combinations are not expressly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure may be combined and / or combined in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or combinations fall within the scope of this disclosure.

[0138] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.

Claims

1. A decision tree testing method, comprising: Multiple decision tree paths of a target decision tree are obtained, wherein each decision tree path has a leaf node, the leaf node represents the expected result of the decision tree path, and the decision tree path also has at least one logical node, each logical node being configured with a logical branch; Based on the logical nodes and logical branches of the decision tree path, select multiple test instances corresponding to multiple decision tree paths from the instance library; Multiple test instances are input into the target decision tree to obtain multiple execution results; and The test results of the target decision tree are obtained by comparing multiple expected results with multiple execution results. The step of selecting multiple test instances corresponding to multiple decision tree paths from the instance library based on the logical nodes and logical branches of the decision tree paths includes: For each decision tree path, the field corresponding to the logical node of the decision tree path is used as the keyword for keyword matching in the instance library; If a first target instance is matched from the instance library, filtering is performed on at least one of the first target instances based on the logical branches of the logical nodes; and If a second target instance is obtained by filtering from the first target instance, a preset number of instances are selected from the second target instance as test instances corresponding to the decision tree path.

2. The method according to claim 1, further comprising: If a first target instance cannot be matched from the instance library, or if a second target instance cannot be filtered from the first target instance, a test instance corresponding to the decision tree path is generated based on the fields corresponding to the logical node and the logical branches of the logical node. as well as The test instance is stored in the instance library.

3. The method according to claim 1, wherein, The step of inputting multiple test instances into the target decision tree to obtain multiple execution results includes: For each test instance, the test instance is input multiple times into the target decision tree to obtain multiple decision results; and If all the decision results are consistent, the execution result of the test instance is determined as the decision result.

4. The method according to claim 3, further comprising: If there is a decision result that is inconsistent with other decision results among the multiple decision results, the path information of the decision tree path corresponding to the test instance will be returned to the terminal device for manual verification.

5. The method according to claim 1, further comprising: For each decision tree path, if the expected result corresponding to the decision tree path is inconsistent with the execution result corresponding to the decision tree path, the path information of the decision tree path is returned to the terminal device for manual verification.

6. A decision tree testing device, comprising: The acquisition module is used to acquire multiple decision tree paths of the target decision tree, wherein each decision tree path has a leaf node, the leaf node represents the expected result of the decision tree path, and the decision tree path also has at least one logical node, each logical node being configured with a logical branch. The first processing module is used to select multiple test instances corresponding to multiple decision tree paths from the instance library based on the logical nodes and logical branches of the decision tree path. The second processing module is used to input multiple test instances into the target decision tree respectively, and obtain multiple execution results; and The comparison module is used to compare multiple expected results with multiple execution results to obtain the test results of the target decision tree; Specifically, the first processing module is used for: For each decision tree path, the field corresponding to the logical node of the decision tree path is used as the keyword for keyword matching in the instance library; If a first target instance is matched from the instance library, filtering is performed on at least one of the first target instances based on the logical branches of the logical nodes; and If a second target instance is obtained by filtering from the first target instance, a preset number of instances are selected from the second target instance as test instances corresponding to the decision tree path.

7. An electronic device, comprising: One or more processors; Memory, used to store one or more instructions. When the one or more instructions are executed by the one or more processors, the one or more processors cause the one or more processors to implement the method of any one of claims 1 to 5.

8. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method of any one of claims 1 to 5.

9. A computer program product comprising computer-executable instructions, which, when executed, are used to implement the method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Test method and device based on decision tree

    CN110908896A