% INPUTS:
% data = MxN matrix, where M = observations and N = features
% labels = Mx1 matrix with the true labels of each observation
% k = nearest neighbor value for relieff algorithm
% kFold = fold value for Cross Validation

% OUTPUTS: the classifier's performance summary


%% Version 1.0
%function [output1, output2, eMin1, eMin2, lastValue1, lastValue2, lastValue3] = VIBES(X, Y, ranked, base, fold, isDependent)
function [output1, eMin1, lastValue1] = VIBES(X, Y, ranked, base, fold, isDependent)
    [row, col] = size(X);
    [hPredictions, predictionError, Mdl] = generateModels(X, Y, ranked, base, fold, isDependent );
    
    [ePrediction1, index1, lastValue1, accuracyValue] = generateEnsemble_Opt( Y, hPredictions);
    
%     options = gaoptimset('PopulationType', 'bitstring');
%     FitnessFcn=@(x)generateEnsemble_GA( x, Y, hPredictions);
%     %tic;
%     [index2, acc, exitflag, Output] = ga(FitnessFcn, col+1, options);
%     %b=toc;
%     lastValue2 = Output.generations;
%     lastValue3 = Output.funccount;
% %     %fprintf('GA: %f\n', b);
    
     output1 = generateStatistics( Y, ePrediction1, index1 );
     output1.BaseLearnerModels = Mdl;
     output1.AccuracyValues = accuracyValue;
%     ind = find(index2);
%     ePrediction2 = ensembleHypotesis(Y, hPredictions(:, ind));
%    output2 = generateStatistics( Y, ePrediction2, ind);

    %performanceSummary( output );
    
    [~, ~, ~, ~, eMin1] = estimatedError(predictionError, index1, row);
%      [~, ~, ~, ~, eMin2] = estimatedError(predictionError, ind, row);
end