How do I apply structures for data manipulation of CSV data
3 ビュー (過去 30 日間)
古いコメントを表示
%Import Existing Data
bank = ImportBankData('bank-full.csv');
names = bank.Properties.VarNames;
% Remove unnecessary double quotes from certain attributes
bank = datasetfun(@removequotes,bank,'DatasetOutput',true);
% Convert all the categorical variables into nominal arrays
[nrows, ncols] = size(bank);
category = false(1,ncols);
for i = 1:ncols
if isa(bank.(names{i}),'cell') || isa(bank.(names{i}),'nominal')
category(i) = true;
bank.(names{i}) = nominal(bank.(names{i}));
end
end
% Logical array keeping track of categorical attributes
catPred = category(1:end-1);
% Set the random number seed to make the results repeatable in this script
rng('default');
%Visualize Data
% Bank balance vs. Last call duration plot, differentiated by outcome of the campaign
gscatter(bank.balance,bank.duration,bank.y)
% Label the plot
xlabel('Bank balance')
ylabel('Last contact duration')
title('Outcome')
% Response
Y = bank.y;
disp('Marketing Campaign')
tabulate(Y)
% Predictor matrix
X = double(bank(:,1:end-1));
I have the following questions
- names = bank.properties.VarName
- Can Matlab automatically do the Removal of double quotes without writing the program?
- I want to apply structures in selecting my response just like 'bank.y'.
I tried applying machine learning with the techniques but it is nothing working for me. This ends up giving me Struct contents reference from a non-struct array object" when tried this names = bank.Properties.VarNames" with the same dataset from UCI.
1 件のコメント
Walter Roberson
2017 年 3 月 28 日
Is ImportBankData the function from https://www.mathworks.com/matlabcentral/fileexchange/42744-machine-learning-with-matlab/content/Machine%20Learning/Classification/ImportBankData.m ?
Which MATLAB version are you using? Do you have Statistics toolbox?
回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!