A node for use in manually creating decision trees, representing a specific question and possible answers, or an action that follows from answering other questions.
- iOS 10.0+
- macOS 10.12+
- Mac Catalyst 13.0+Beta
- tvOS 10.0+
GKDecision instance represents an element in a decision tree (a
GKDecision object). Decision trees contain two kinds of nodes. Some nodes, including the tree’s root node, represent individual decisions to be made (also called a question or attribute) and reference child nodes for each possible outcome of (or branch from) that decision. Each branch can lead to another question node, or to a leaf node—nodes that have no branches represent a final outcome (or action) to result from the tree’s decision-making process. After creating a decision tree from a set of nodes, you can present the tree with a set of inputs (values for attributes, or answers to questions) and the tree provides a final action that follows from the branches corresponding to each attribute.
There are two ways to create a decision tree. You use the
GKDecision class directly only when you want to define an entire decision tree manually—that is, to specify each question, the possible branches from each question, and the possible final actions. To create such a decision tree, start with the
init(attribute:) initializer, then use the methods listed in Creating Child Nodes for Decision Branches to add branches to the tree.