Skip to content

Instantly share code, notes, and snippets.

@shravankumar147
Created May 8, 2017 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shravankumar147/a306a80bb821904ea62682ea512264c6 to your computer and use it in GitHub Desktop.
Save shravankumar147/a306a80bb821904ea62682ea512264c6 to your computer and use it in GitHub Desktop.
Used as it is, except some version compatibility changes. lines: 3,4,12-16
clear all;
clc;
stype={'char','pos','bar','pie'}; %modified here
load('S2.mat') %S2.mat is the correct response data w.r.t. response_fld0.05_correct.mat
eegdata=S;
for type=1:4
% load('processed_data\features2_normalized.mat');
% load('processed_data\features_mRMR_400mid.mat');
% load('processed_data\processed_target_2s1.mat');
% load('processed_data\features_target_final.mat');
load('etc\feature_response_fld_0.05.mat')
%% This is where I modified for version compatibility
tp = processed_meta_2s(:,4);
l = strcmp(tp,stype{type});
idx = find(l);
S=eegdata;
%%
S=S(idx,:);
nback_target=nback_target(idx,:);
fprintf('Type : %s\n',stype{type});
fprintf('Number of samples for..\n');
fprintf('0,1,2,3 back respectively :%4d,%4d,%4d,%4d\n',size(find(nback_target==0),1),size(find(nback_target==1),1),size(find(nback_target==2),1),size(find(nback_target==3),1));
fprintf('--------------------------------------------\n');
fprintf(' Test Acc F1 score\n');
for j=0:2
for k=(j+1):3
num1=j;
num2=k;
idx1=find(nback_target==num1);
idx2=find(nback_target==num2);
data1=S(idx1,:);
data2=S(idx2,:);
A=[data1;data2];
Y=[ones(size(idx1,1),1); -1*ones(size(idx2,1),1)];
ridx=randperm(size(Y,1));
A=A(ridx,:);
Y=Y(ridx,:);
[w gamma train test trainf1 testf1 time nu]=psvm(A,Y,10,0,false,1);
% [w gamma train test time nu] = n_psvm(A,Y,0.5,5);
fprintf('%d vs %d %10.2f %10.2f\n',num1,num2,test,testf1);
end
end
fprintf('--------------------------------------------\n');
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment