Azzera filtri
Azzera filtri

How to remove compare 2 arrays so that when there is a in a column, it removes the column in another array

1 visualizzazione (ultimi 30 giorni)
cvs_data =csvread('spruce tree timber quality.csv',1,0)
expert_ratings = cvs_data(:,12)' %inputs
inputs = cvs_data(:,1:11)';
correct_labels = zeros(3,length(expert_ratings));
bad = 0;
good=0;
excellent=0;
histogram(expert_ratings)
Skew1 = skewness(expert_ratings)
for k =1 : length(expert_ratings)%length(expert_ratings)
quality = cvs_data(k,12)';
if quality >= 1 && quality <=4
bad = bad+1;
correct_labels(1:3, k) =[1; 0 ; 0];
end
if quality >= 5 && quality <=6
good = good+1;
correct_labels(1:3, k) =[0; 1 ; 0];
end
if quality >= 7 && quality <=10
excellent = excellent+1;
correct_labels(1:3, k) =[0; 0 ; 1];
end
end
bad
good
excellent
correct_labels
%find bad data
%remove bad data or average it to make it good
%select the same amount of data for all qualities of trees
%remove noise from data
[good_data,rows_rem] = rmoutliers(cvs_data)
transposed_rows = rows_rem'
correct_labels
Hello. I am trying to remove a column from the correct_labels array, when there is a 0 in the corresponding column in the transposed_rows array. How could I go about doing this? Any help would be greatly appreciated.

Risposta accettata

dpb
dpb il 9 Ott 2022
Modificato: dpb il 9 Ott 2022
You have only one row logical but three rows of labels???
But, assuming that's expected and the need is to remove all columns that are false, that means KEEP those for which is true --
correct_labels=correct_labels(:,transposed_rows);
From the above, sample of the data, looks like you're ony going to keep a very small fraction...sure you're interpreting this correctly?
If, indeed, it is the obverse, then
correct_labels=correct_labels(:,~transposed_rows); % keep those columns NOT true
or, instead of keeping; remove others...
correct_labels(:,transposed_rows)=[]; % remove those columns ARE true
  2 Commenti
Killian Flynn
Killian Flynn il 9 Ott 2022
Yeah sorry I meant do delete the column in correct_labels when there is a 1 in the transposed_rows array.
dpb
dpb il 9 Ott 2022
Then you just negate the logical to keep or remove the logical with original sense...I'll add the code in Answer...

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Tables in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by