function [mean_value,var_value,rmse_value] = driver2_cross_val()
    sampling_rate = 12000;
    speed = 1772/60;
    window_size = ceil(sampling_rate/speed); %samples per cycle
    n_level = 6;
    n_fold = 5;
    
    %Training Feature Extraction
    load IR_10dB_12K_9sev_train.mat;
    [value1,n_data_points1] = feat_select(sev1,n_level,window_size);
    [value2,n_data_points2] = feat_select(sev9,n_level,window_size);
    points_per_fold = floor(n_data_points1/n_fold);

    value1_part1 = value1(1:points_per_fold,:);
    value1_part2 = value1(1*points_per_fold+1:2*points_per_fold,:);
    value1_part3 = value1(2*points_per_fold+1:3*points_per_fold,:);
    value1_part4 = value1(3*points_per_fold+1:4*points_per_fold,:);
    value1_part5 = value1(4*points_per_fold+1:5*points_per_fold,:);
    
    value2_part1 = value2(1:points_per_fold,:);
    value2_part2 = value2(1*points_per_fold+1:2*points_per_fold,:);
    value2_part3 = value2(2*points_per_fold+1:3*points_per_fold,:);
    value2_part4 = value2(3*points_per_fold+1:4*points_per_fold,:);
    value2_part5 = value2(4*points_per_fold+1:5*points_per_fold,:);
    size(value2)
    size(value2_part1)
    size(value2_part2)
    size(value2_part3)
    size(value2_part4)
    size(value2_part5)
    
    
    %Parameters
    train_label_values = [1 9];
    kernel = 'linear';
    c_value = -5:1:3; %changed from 15 to 5
    epsilon_value = [0.001:0.001:0.01 0.01:0.01:0.10];
    gamma_value = 0; %-15:1:3;
    var_value = 0;
    rmse_value = 0;
    n_train_datapoints = points_per_fold*(n_fold-1);
    n_train_classes = 2;
    n_test_datapoints = points_per_fold;
 
%FOR FIRST FOLD    
    train_data_value1 = [value1_part1;value1_part2;value1_part3;value1_part4];
    train_data_value2 = [value2_part1;value2_part2;value2_part3;value2_part4];
    train_data = [train_data_value1;train_data_value2]; 
    test_data = value1_part5;
    test_class_values = 1;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value = var_value + dum_var;
    rmse_value = rmse_value + dum_rmse;
    test_data = value2_part5;
    test_class_values = 9;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);
%FOR SECOND FOLD    
    train_data_value1 = [value1_part2;value1_part3;value1_part4;value1_part5];
    train_data_value2 = [value2_part2;value2_part3;value2_part4;value2_part5];
    train_data = [train_data_value1;train_data_value2]; 
    test_data = value1_part1;
    test_class_values = 1;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);
    test_data = value2_part1;
    test_class_values = 9;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);
%FOR THIRD FOLD    
    train_data_value1 = [value1_part3;value1_part4;value1_part5;value1_part1];
    train_data_value2 = [value2_part3;value2_part4;value2_part5;value2_part1];
    train_data = [train_data_value1;train_data_value2]; 
    test_data = value1_part2;
    test_class_values = 1;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);
    test_data = value2_part2;
    test_class_values = 9;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);
%FOR FOURTH FOLD    
    train_data_value1 = [value1_part5;value1_part1;value1_part2;value1_part3];
    train_data_value2 = [value2_part5;value2_part1;value2_part2;value2_part3];
    train_data = [train_data_value1;train_data_value2]; 
    test_data = value1_part4;
    test_class_values = 1;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);
    test_data = value2_part4;
    test_class_values = 9;
    [mean_value,dum_var,dum_rmse] = para_optimization(train_data,test_data,n_train_datapoints,n_train_classes,test_class_values,n_test_datapoints,kernel,c_value,epsilon_value,gamma_value,train_label_values);
    var_value(:,1) = var_value(:,1) + dum_var(:,1);
    rmse_value(:,1) = rmse_value(:,1) + dum_rmse(:,1);      
end