-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathdownsample.m
More file actions
16 lines (15 loc) · 779 Bytes
/
downsample.m
File metadata and controls
16 lines (15 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function [X_Test_ds,Y_Test_Desired_ds]= downsample(X_Test,Y_Test_Desired,NoS)
%NoS=10; %number of samples perclass
[class_label,index_perclass,~]= unique(Y_Test_Desired);
Samp_Index_perclass=zeros(length(class_label),NoS);
for i= class_label'
if i== length(class_label)
Samp_Index_perclass(i,:) = index_perclass(i)+randperm((length(Y_Test_Desired)-index_perclass(i)),NoS);
else
Samp_Index_perclass(i,:) = index_perclass(i)+randperm((index_perclass(i+1)-index_perclass(i)),NoS);
end
end
Samp_Index= Samp_Index_perclass(:);
X_Test_ds = X_Test(:,Samp_Index); %12197*NoF
Y_Test_Desired_ds = Y_Test_Desired(Samp_Index); %the desire output of target(class value)
end