If you want to read the original article, click here Decision tree regression and Classification.
Decision tree regression and Classification, Multiple linear regression can yield reliable predictive models when the connection between a group of predictor variables and a response variable is linear.
Non-linear approaches, on the other hand, can perform better when the relationship between a set of predictors and a response is very non-linear and complex.
A regression tree is a method that uses the target variable to predict the value of the variable. You might want to predict the selling prices of a product, which is a continuous dependent variable, as an example of a regression type problem.
This will be determined by both continuous criteria and categorical factors.
Decision tree regression and Classification, when should you utilize it?
When a dataset needs to be divided into classes that correspond to the response variable, classification trees are used. The classes Yes or No are frequently used.
In other words, there are only two of them, and they are mutually exclusive. There may be more than two classifications in some circumstances, in which case a classification tree method version is utilized.
When the response variable is continuous, however, regression trees are used. A regression tree is employed, for example, if the response variable is the price of a property or the temperature of the day.
To put it another way, regression trees are used to solve prediction problems, whereas classification trees are used to solve classification problems.
Classification and regression trees, sometimes known as CART, are an example of a non-linear approach.
This article will focus more on CART models, as the name implies, generating decision trees that predict the value of a response variable using a set of predictor variables.
What is CART model?
The first predictor variable at the top of the tree is the most important, i.e. the one that has the greatest influence on predicting the response variable’s value.
Terminal nodes are the regions at the bottom of the tree. There are three-terminal nodes on this tree.
Building CART Models: A Step-by-Step Guide
To create a CART model for a given dataset, we can utilize the steps below.
Step 1: To create a big tree on the training data, use recursive binary splitting.
To begin, we use the following method to create a regression tree using a greedy algorithm known as recursive binary splitting:
Consider all of the predictor variables X1, X2,…, Xp, as well as all possible cut point values for each of the predictors, then select the predictor and cut point that produces the tree with the lowest residual standard error (RSS).
We need to set the predictor and cut point for classification trees so that the resulting tree has the lowest misclassification rate.
Continue this method until each terminal node has fewer than a certain number of observations.
This algorithm is greedy because it picks the optimum split to make at each phase of the tree-building process based solely on that step, rather than looking ahead and selecting a split that will lead to a better overall tree in a later step.
Step 2: Apply cost complexity pruning to the huge tree to generate a list of the best trees as a function of α.
After we’ve developed a large tree, we’ll need to prune it using a technique called cost complexity pruning, which works like this,
Find the tree that minimizes RSS + α|T| for each conceivable tree with T terminal nodes.
It’s worth noting that when the value of α grows larger, trees with more terminal nodes are penalized. This keeps the tree from becoming too complicated.
For each value of α, this procedure yields a list of the best trees.
Step 3: To pick α, use k-fold cross-validation.
We can use k-fold cross-validation to determine the value that minimizes the test error once we’ve found the optimal tree for each value of α.
Step 4: Final model.
We can select now the final model that best matches the value of α.
CART Models’ Advantages and Disadvantages
Following advantages have in CART models,
CART models are simple to comprehend.
They can be used to solve problems involving regression and classification.
Let’s see the disadvantages of CART models,
They aren’t as accurate as other non-linear machine learning algorithms at predicting outcomes.
The predicted accuracy of several decision trees can be increased by aggregating them using methods like bagging, boosting, and random forests.
Subscribe to our newsletter!
To read more visit Decision tree regression and Classification.
If you are interested to learn more about data science, you can find more articles here finnstats.