how do I move mixed (numeric, categorical, logical} data into a table for subsequent analysis

1 view (last 30 days)
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?

Answers (1)

Nachiket Katakkar
Nachiket Katakkar on 23 Feb 2017
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);
  1 Comment
Richard Palmer
Richard Palmer on 23 Feb 2017
Thanks! Do you know how to get from the carsmall to a dataset that can be processed by the neural net packages. I setup a tbl like yours "by hand" and got fitglm to work. However, I don't know how to get the tbl into a form amenable for neural net analysis. Since I have a lot of nominal data in my dataset, I need a way to mechanize this.
Again, thanks!

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!