Effacer les filtres
Effacer les filtres

how to imply array of zeros and ones to my dataset, help me plz

1 vue (au cours des 30 derniers jours)
Ayman Alotaibi
Ayman Alotaibi le 13 Mar 2018
hi guy , I've those tasks, and I did my best to get them all done, this is what I've done so far. plz help me with task3 to get it done,
data=readData('adult.csv',',');
hdr=fieldnames(data)
N=length(data.income)
Task 1
Split the dataset into two subsets, say, "train" and "test", with the train set containing 80% of the data and the test set containing the remaining 20%.
Splitting means to generate a logical index of length equal to the number of observations in the dataset, with 1 for a training sample and 0 for at test sample.
Output: logical arrays called idxTrain and idxTest.
p=0.8; %train which is %80
numOfOne= N*p;
idxTrain=[ones(1, numOfOne)]; // array of ones %80
idxTest=[ zeros(1, N - numOfOne)]; // array of zeros %20
Task 2 using unique() convert the "race" categories into numerical indices. Then compute the popluation counts of the "race" categories.
Output: array E with the population counts of the race variable.
x=data.race(:);
[ux,~,idx]=unique(x);
idx=idx(:);
numbers = accumarray (idx , ones(size(idx)) );
Task 3 using accumarray compute the observed counts for the train and for the test subsets. Call tese TrainO and TestO, respectively.
Output: arrays TrainO and TestO with the race counts in each of the 2 subsets.
TrainO=
TestO=

Réponses (0)

Catégories

En savoir plus sur Octave dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by