1 #ifndef GRAIL_DECISION_TREE_H
2 #define GRAIL_DECISION_TREE_H
4 #include "../ISimulatedGameHeuristic.hh"
5 #include "DecisionNode.h"
6 #include <unordered_set>
7 #include <unordered_map>
8 #include <initializer_list>
14 class ISimulatedGameAction;
19 struct IDecisionTreeSerializer;
43 virtual std::unique_ptr<ISimulatedGameAction>
GetAction()
const override;
52 void SetColumnNames(
const std::initializer_list<std::string>& consecutiveNames);
62 void ConstructDefaultColumnNames();
64 std::unique_ptr<DecisionNode<ISimulatedGameAction>> root;
65 std::unique_ptr<IVectorizer> vectorizer;
66 std::unordered_set<int> usedConsiderationIndices;
67 std::unordered_map<int, std::string> columnNames;
Definition: Dataset.hh:20
The main class encapsulating the decision tree algorithm.
Definition: DecisionTree.hh:25
void SetVectorizer(std::unique_ptr< IVectorizer > vectorizer)
Moves the vectorizer passed as parameter to the DecisionTree. The DecisionTree uses it to provide act...
Definition: DecisionTree.cpp:79
void Deserialize(IDecisionTreeSerializer< ISimulatedGameAction > &serializer)
Populates the tree based on the given serializer.
Definition: DecisionTree.cpp:31
IVectorizer & GetVectorizer() const
Returns the reference to the currently used vectorizer by the DecisionTree. Do not use this method,...
Definition: DecisionTree.cpp:74
DecisionTree(std::unique_ptr< IVectorizer > vectorizer)
Constructs a new decision tree object. You have to specify a proper vectorizer object that will be us...
Definition: DecisionTree.cpp:13
void SetColumnName(int columnIndex, const std::string &name)
This will make the Print() function output the name instead of Column[columnIndex]....
Definition: DecisionTree.cpp:62
virtual bool IsHeuristicSituation(const ISimulatedGameUnit &unit) const final
Inherited via SimulatedGameHeuristic.
Definition: DecisionTree.cpp:57
void Construct(Dataset &dataset, int maxDepth=decisionTreeMaxDepth)
Runs the decision tree construction algorithm (C45). @dataset contains the training data....
Definition: DecisionTree.cpp:36
void Serialize(IDecisionTreeSerializer< ISimulatedGameAction > &serializer) const
Serializes the content of the tree into the passed serializer object.
Definition: DecisionTree.cpp:26
void SetColumnNames(const std::initializer_list< std::string > &consecutiveNames)
This will make the Print() function output the names instead of Column[columnIndex]....
Definition: DecisionTree.cpp:67
virtual std::unique_ptr< ISimulatedGameAction > GetAction() const override
Inherited via SimulatedGameHeuristic.
Definition: DecisionTree.cpp:48
void Print()
Prints the decision tree in a very diagnostic fashion onto standard output (cout).
Definition: DecisionTree.cpp:20
Base class of a unit in the SimulatedGame framework. A unit represents part of the game-state and pef...
Definition: ISimulatedGameUnit.hh:27
Interface that encapsulates an algorithm responsible for action-selection inside SimulatedGame (MCTS)...
Definition: ISimulatedGameHeuristic.hh:19
A base class for an object that is passed to Serialize() and Deserialize() methods of DecisionTree....
Definition: IDecisionTreeSerializer.hh:21
Classes implementing this interface provide training data in the offline learning process.
Definition: IVectorizer.hh:17