필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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.

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by