Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

dpb
dpb am 9 Okt. 2022
Bearbeitet: dpb am 9 Okt. 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 Kommentare
Killian Flynn
Killian Flynn am 9 Okt. 2022
Yeah sorry I meant do delete the column in correct_labels when there is a 1 in the transposed_rows array.
dpb
dpb am 9 Okt. 2022
Then you just negate the logical to keep or remove the logical with original sense...I'll add the code in Answer...

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by