
clear all;clc;close all
%% Load data:

% load('jenEEGparametry.mat'); % Input - feature matrix MxN, M - number of epochs, N - number of features
Input=MATICEPARAMETRU;
% Input=jen_casove;
% Input=jen_frekvencni;
% Input=jenEEGparametry;
% Input=vsechny_dohromady;
% load('matice_fazi_celkova.mat'); % Output - vector of correspondings target values Mx1 matice_fazi_10pac_vybrane.mat
Output=matice_fazi;
% Output=matice__fazi_celkova;
%% Temporal variables:
AccLDA_Cont=[];SeLDA_Cont=[];SpLDA_Cont=[];TDLDA_Cont=[];TReqLDA_Cont=[];
AccLDA_LVH=[];SeLDA_LVH=[];SpLDA_LVH=[];TDLDA_LVH=[];TReqLDA_LVH=[];
AccLDA_OPT=[];SeLDA_OPT=[];SpLDA_OPT=[];TDLDA_OPT=[];TReqLDA_OPT=[];

AccKNN_Cont=[];SeKNN_Cont=[];SpKNN_Cont=[];TDKNN_Cont=[];TReqKNN_Cont=[];
AccKNN_LVH=[];SeKNN_LVH=[];SpKNN_LVH=[];TDKNN_LVH=[];TReqKNN_LVH=[];
AccKNN_OPT=[];SeKNN_OPT=[];SpKNN_OPT=[];TDKNN_OPT=[];TReqKNN_OPT=[];

AccSVM_Cont=[];SeSVM_Cont=[];SpSVM_Cont=[];TDSVM_Cont=[];TReqSVM_Cont=[];
AccSVM_LVH=[];SeSVM_LVH=[];SpSVM_LVH=[];TDSVM_LVH=[];TReqSVM_LVH=[];
AccSVM_OPT=[];SeSVM_OPT=[];SpSVM_OPT=[];TDSVM_OPT=[];TReqSVM_OPT=[];

%% CLASSIFICATION by 10-fold cross-validation:
       % Function for classification:
       % [meanAcc, meanSe, meanSp, TimeReq]=crossClassMulti(Input, Output, ClassType, Opts, FS, Stand), 
       % where:
       %       Input - features matrix
       %       Output - targets matrix
       %       ClassType - type of classification model: 0 - DF, 1 - kNN, 3 - SVM, 2 - NB
       %             for DF: Opts represents type of DF - 'diaglinear' or 'diagquadratic';
       %             for kNN: Opts represents 'k' number - '1','5',...;
       %             for SVM: Opts represents type of model - 'linear' or 'rbf'
       %       FS - feature set name, e.g. 'ParametryEEG', 'ParametryEOG', 'Spektralni'
       %       Stand - use of non-standardized '0' or standardized '1' data    
     
    % Generation of k-fold validation indices:
    rng(0,'twister'); % begin from the same numbers for random samples generation
    nfold=10;% or 5 if there is only small data set
    cv = cvpartition(Output,'kfold',nfold);  
    indicesCV = zeros(size(Output));
    for i=1:nfold
        indicesCV(cv.test(i)) = i;
    end

    Stand = 1; % or =0, see above
    
    % Select classification method:
% %     crossKlasifikace(ParamClass, OutClass, indices, ClassType, Opts, FS, Stand)
    
FS = 'Total';% kompletni matice parametru;
     
%     SVM:
    Opts ='linear';
    [FmG, Fm, outtr]=crossKlasifikace(Input, Output,indicesCV,3, Opts, FS, Stand);
%     clear Acc Se Sp TD TReq
    
    Opts ='rbf';
    [Acc, Se, Sp]=crossKlasifikace(Input, Output,indicesCV,3, Opts, FS, Stand);
    AccSVM_Cont=[AccSVM_Cont Acc]; SeSVM_Cont=[SeSVM_Cont Se];SpSVM_Cont=[SpSVM_Cont Sp];
%     TReqSVM_Cont=[TReqSVM_Cont TReq];
%     clear Acc Se Sp TD TReq
 
 
