Cpp ML Library  1.0.0
A library of Machine Learning Algorithmns seen from the Udemy course Machine Learning A to Z.
Classes | Public Member Functions | List of all members
DecisionTreeClassifier Class Reference

Implements a Decision Tree Classifier. More...

#include <DecisionTreeClassifier.hpp>

Public Member Functions

 DecisionTreeClassifier (int max_depth=5, int min_samples_split=2)
 Constructs a DecisionTreeClassifier. More...
 
 ~DecisionTreeClassifier ()
 Destructor for DecisionTreeClassifier.
 
void fit (const std::vector< std::vector< double >> &X, const std::vector< int > &y)
 Fits the model to the training data. More...
 
std::vector< int > predict (const std::vector< std::vector< double >> &X) const
 Predicts class labels for given input data. More...
 

Detailed Description

Implements a Decision Tree Classifier.

Constructor & Destructor Documentation

◆ DecisionTreeClassifier()

DecisionTreeClassifier::DecisionTreeClassifier ( int  max_depth = 5,
int  min_samples_split = 2 
)

Constructs a DecisionTreeClassifier.

Parameters
max_depthThe maximum depth of the tree.
min_samples_splitThe minimum number of samples required to split an internal node.

Member Function Documentation

◆ fit()

void DecisionTreeClassifier::fit ( const std::vector< std::vector< double >> &  X,
const std::vector< int > &  y 
)

Fits the model to the training data.

Parameters
XA vector of feature vectors.
yA vector of target class labels.

◆ predict()

std::vector< int > DecisionTreeClassifier::predict ( const std::vector< std::vector< double >> &  X) const

Predicts class labels for given input data.

Parameters
XA vector of feature vectors.
Returns
A vector of predicted class labels.

The documentation for this class was generated from the following file: