Decision Tree
The Decision Tree organizes decisions in a hierarchical structure, where each decision point corresponds to a question about the data. From these questions, the model splits the data into subsets until it reaches a final classification. This model is widely used due to its interpretability, as the decision-making process is easy to understand. It is efficient for creating explainable models, even in complex situations.
The training of the model is time-consuming compared to other models, but once trained, the database is not required for making predictions. It is possible to save and import the completed training into an extremely lightweight file.
EXAMPLE OF USE
CLASSES AND METHODS GUIDE
TDecisionTree
FDataset : TAIDatasetClassification; : access the current database contained in the model.
procedure ClearDataset; : cleans the dataset.
constructor Create(aDepth: Integer; aSplitCriterion: TSplitCriterion); overload; : creates a new tree to be trained.
aDepth : tree depth.
splitcriterion = TSplitCriterion : [scGini, scEntropy].
constructor Create(aTrainedFile : String); overload; : creates the object by loading the structure from an already trained file.
aTrainedFile : CSV file path.
procedure Train(aTrainingData : String; aHasHeader : Boolean = True); overload; : trains the model and generates the nodes based on the given data.
aTrainingData : CSV file path.
aHasHeader : indicates whether the file has a header.
procedure Train(aTrainingData : TDataSet); overload; : performs the training and generates the nodes based on the provided data.
aTrainingData : TDataSet object that contains the data that will be used for training.
function Predict(aSample: TArray<Double>; aInputNormalized : Boolean = False): String; : predicts the best category for the sample.
aSample : sample to be analyzed.
aInputNormalized : it should be set to true only if the input data has already been normalized outside the component (which should be done using the range saved in the object).
procedure LoadFromFile(const FileName: string); : loads the tree structure from a file.
procedure SaveToFile(const FileName: string); : saves the generated tree structure to a file.
Last updated