How do I apply structures for data manipulation of CSV data
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
%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 Commento
Walter Roberson
il 28 Mar 2017
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?
Risposte (0)
Vedere anche
Categorie
Scopri di più su Data Types in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!