DecisionTreeBase class

DecisionTreeBase is a semi-virtual parent class that contains methods used in both DecisionTreeClassifier and DecisionTreeRegressor.

Derived classes

class DecisionTreeClassifier

Constructors, destructors, conversion operators

DecisionTreeBase(std::string lossCriterion, double maxFeatures, int minSamplesSplit, int maxDepth, int minSamplesLeaf, double minImpurityDecrease)
Construct a new DecisionTreeBase object.

Public functions

void fit(DataFrame* trainData) virtual
This method creates the decision tree, which can be used later for prediction.
auto predict(DataFrame* testData) -> DataFrame* pure virtual
auto getLossCriterion() const -> std::string
void printTree()

Protected variables

DecisionNode* root

Private functions

auto computeLoss(std::vector<double>) -> double pure virtual
auto getTruthVector(DataFrame*) -> std::vector<double> pure virtual
void printTruthVector(std::vector<double> truthVector) pure virtual

Function documentation

DecisionTreeBase::DecisionTreeBase(std::string lossCriterion, double maxFeatures, int minSamplesSplit, int maxDepth, int minSamplesLeaf, double minImpurityDecrease)

Construct a new DecisionTreeBase object.

Parameters
lossCriterion type of loss calculation used
maxFeatures number of features used for splitting a node
minSamplesSplit minimun number of samples at root to consider splitting
maxDepth maxiumum depth of the decision tree
minSamplesLeaf minimum number of samples in child leafs to consider the split
minImpurityDecrease minimum improvement in loss calculation to consider the split

void DecisionTreeBase::fit(DataFrame* trainData) virtual

This method creates the decision tree, which can be used later for prediction.

Parameters
trainData