-
Notifications
You must be signed in to change notification settings - Fork 0
aurora: Decision Tree
Clouke edited this page May 5, 2023
·
2 revisions
The Decision Tree is built by passing a list of maps as the training data, with each map representing a single instance in the dataset. The target attribute is also specified.
DecisionTree<String> tree = new DecisionTree<>(data, targetAttribute);
Or build an empty DecisionTree:
DecisionTree<String> tree = new DecisionTree<>();
tree.train(data, targetAttribute);
String prediction = tree.predict(instance);
List<Map<String, String>> instance = new ArrayList<>();
Map<String, String> data = new HashMap<>();
for (MessageNode node : nodes) {
if (nodes.size() == i + 1) break; // no next node
MessageNode nextNode = nodes.get(i + 1);
String word = node.content;
String reply = nextNode.content;
data.put(word, reply);
i++;
}
instance.add(data);
tree.train(instance, "your_target_here");