% below are the load commands for different databases
% depending on which database you would like to be processed
% just uncomment the related lines

allMyDatasets = {
    'cocomo81','cocomo81o','cocomo81e','cocomo81s',...
    'nasa93','nasa93_center_1','nasa93_center_2','nasa93_center_5',...
    'desharnais','desharnaisL1','desharnaisL2','desharnaisL3',...
    'sdr'...
    'albrecht','china','finnish','kemerer','maxwell','miyazaki94','telecom1'};



for datasetCounter = 1:size(allMyDatasets,2)
    cd 'datasets';
    eval(['load ',char(allMyDatasets(datasetCounter)),'.csv;']);
    eval(['dataset = ',char(allMyDatasets(datasetCounter)),';']);
    eval(['clear ',char(allMyDatasets(datasetCounter)),';']);
    cd ..;
    
    % train is the dataset minus the selected row
    train = dataset;
    
    % now start predictions
    % the one below -treeK- is our guy to defend
    [myTree, myRoot] = simpleGACGenerator(train);
    
    % prune high variance sub-trees and store the instances in low variance
    % sub-trees
    [cleanedSelectedInstances] = gacPruner(myTree, myRoot);
       
    % save instances
    cd 'datasets';
    eval(['csvwrite(''',char(allMyDatasets(datasetCounter)),'_reduced.csv'',cleanedSelectedInstances);']);
    cd ..;
    
end

