Using categorical predictors in regression tress

1 view (last 30 days)
I was wondering if it is possible to use categorical predictors in regression trees.
For example, when considering the "carsmall" example on the Mathworks website it provides
tree = fitrtree([Weight, Cylinders],MPG,'categoricalpredictors',2,'MinParentSize',20,'PredictorNames',{'W','C'})
Where "Weight" and "Cylinders" are both matrices. However, using
tree = fitrtree([Weight, Model],MPG,'categoricalpredictors',2,'MinParentSize',20,'PredictorNames',{'W','M'})
doesn't work as "Model" is a character array.
Is there a way to use word (char or string) categorical predictors using fitrtree or fitctree? Or should I be using something else?

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!