Decision tree non-numerical data statistics toolbox

11 次查看(过去 30 天)
Hi,
It says in the statistics toolbox documentation:Classification trees give responses that are nominal, such as 'true' or 'false'. Regression trees give numeric responses. I am trying to build a decision tree. I am working with numeric (output) and non-numeric data(inputs).I think the classification tree would be more appropriate than the regression tree, or (as the regression tree seems to work just with numeric data). Is it possible to use non-numeric data in order to predict numeric data?And if so, how could I do this with the help of the statistics toolbox?Would Classificationtree.fit be the right choice?
Thank you :)

采纳的回答

Ilya
Ilya 2014-6-16
The type of tree you need is defined by the type of output. If your output is numeric ("numeric" here means that you can do greater and less comparisons and compute a meaningful distance between values), regression tree is the right choice.
For either type of tree, you need to convert your inputs to a numeric matrix. Then you can indicate what variables are non-numeric (categorical) using the 'CategoricalPredictors' parameter; if all your variables are categorical, set it to 'all'.
You can convert your non-numeric data to numeric in many ways. One way would be to use the categorical class in MATLAB on each variable in your data, for example:
>> colors = categorical({'g' 'r' 'b'; 'b' 'r' 'g'});
>> numeric_colors = double(colors);
Then use the new numeric variables as columns in the matrix you pass to the fit function.
  1 个评论
Tania
Tania 2014-7-29
Thanks a lot for your answer & sry for the late reply.
For either type of tree, you need to convert your inputs to a numeric matrix. Then you can indicate what variables are non-numeric (categorical) using the 'CategoricalPredictors' parameter; if all your variables are categorical, set it to 'all'.
- What can I do if only one of my variables is categorical?
Thank you!

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by