Grail (C++)  1.2.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
C45Algorithm.h
1 // Copyright QED Software 2023.
2 
3 #ifndef GRAIL_C45_ALGORITHM_H
4 #define GRAIL_C45_ALGORITHM_H
5 
6 #include <memory>
7 #include <unordered_set>
8 #include "C45IterationParameters.h"
9 #include "C45ValueDecisionCounter.h"
10 #include "Dataset.hh"
11 #include "../DecisionTree/DecisionNode.h"
12 
13 namespace grail
14 {
15 namespace simgames
16 {
17  class ISimulatedGameAction;
18 
19 namespace learn
20 {
26  {
27  public:
34  std::unique_ptr<dt::DecisionNode<ISimulatedGameAction>> ConstructTree(
35  Dataset& dataset,
36  int maxDepth = dt::decisionTreeMaxDepth);
37 
41  const std::unordered_set<int>& GetUsedColumns() const;
42 
43  private:
44  void RunForContinuousColumn(size_t column, double globalEntropy, C45IterationParameters& params);
45  void RunForNominalColumn(size_t column, double globalEntropy, C45IterationParameters& params);
46  std::unique_ptr<dt::DecisionNode<ISimulatedGameAction>> Iterate(C45IterationParameters parameters);
47  std::unique_ptr<dt::DecisionNode<ISimulatedGameAction>> PerformSplit(
48  C45IterationParameters& params,
49  int bestColumnIndex);
50 
51  const ISimulatedGameAction* globalFrequentAction = nullptr;
52  std::unordered_set<int> usedColumns;
53  int maxDepth = 0;
54  int currentDepth = 0;
55  };
56 }
57 }
58 }
59 
60 #endif //GRAIL_C45_ALGORITHM_H
grail::simgames::learn::C45IterationParameters
The whole class should be INTERNAL; part of the private interface.
Definition: C45IterationParameters.h:16
grail::simgames::ISimulatedGameAction
Base class for all actions in SimulatedGame. Derive from it for your actions.
Definition: ISimulatedGameAction.hh:41
grail::simgames::learn::C45Algorithm::ConstructTree
std::unique_ptr< dt::DecisionNode< ISimulatedGameAction > > ConstructTree(Dataset &dataset, int maxDepth=dt::decisionTreeMaxDepth)
Constructs a new decision tree based on the provided dataset. The decision type is given by generic a...
Definition: C45Algorithm.cpp:59
grail::simgames::learn::C45Algorithm::GetUsedColumns
const std::unordered_set< int > & GetUsedColumns() const
Gets indices of columns in the dataset used for learning with the C4.5 Algorithm that were actually u...
Definition: C45Algorithm.cpp:160
grail::simgames::learn::Dataset
Definition: Dataset.hh:23
grail::simgames::learn::C45Algorithm
This class encapsulates the C4.5 Algorithm used to generate a decision tree (see Grail....
Definition: C45Algorithm.h:25