how do I move mixed (numeric, categorical, logical} data into a table for subsequent analysis
1 次查看(过去 30 天)
显示 更早的评论
I am using the adult incomes dataset. It contains numeric and nominal data. It also contains a nominal/logical variable (did income exceed 50k?). fitglm works with a table object. How to I get the appropriate column flags into a table for analysis?
0 个评论
回答(1 个)
Nachiket Katakkar
2017-2-23
An example of moving mixed data types into a single table followed by calling "fitglm" is shown below. This uses the "carsmall" data-set within MATLAB but should be easy to extend to the data you have mentioned:
% Load the carsmall dataset
load carsmall
% Convert values to nominal and logical
Cylinders = nominal(Cylinders);
Weight = Weight > 3000;
% Make a table
tbl = table(Cylinders,Weight,Origin,MPG);
% Fit GLM model
mdl = fitglm(tbl);
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!