function [rmse_value] = predict_residual_life(data,training_indices,labels_all_data,n_level,n_feat,c_value,epsilon_value,gamma_value,kernel,speed)
    sampling_rate = 20000; %12000;%20000;
    speed = speed/60;%500/60;
    window_size = ceil(sampling_rate/speed); %samples per cycle
    total_severity_levels = length(labels_all_data);
    n_severity_level = length(training_indices);
    n_test_severity_leves = total_severity_levels-n_severity_level;
    
    %Training Feature Extraction
    i = 1;
    [value,n_data_points1] = feat_select(data(:,training_indices(i)),n_level,window_size);
    i = 2;
    while(i <= n_severity_level)
        [dum1,n_data_points1] = feat_select(data(:,training_indices(i)),n_level,window_size);
        dum2 = [value;dum1];
        value = dum2;
        i = i + 1;
    end
    [train_data,indeces] = train_feat_select(value,n_feat);
    n_train_datapoints = n_data_points1;
    train_label_values = labels_all_data(training_indices);
    rmse_value = 0;
    j = 1;
    while(j <= total_severity_levels)
        k = 1;
        while(k <= length(training_indices))
            if(j == training_indices(k))
                k = length(training_indices) + 1;
            else
                if(k == length(training_indices))
                    [value,n_data_points_test] = feat_select(data(:,j),n_level,window_size);
                    test_data = value(:,indeces);
                    n_train_classes = length(training_indices);
                    test_class_values = labels_all_data(j);
                    n_test_datapoints = n_data_points_test;
                    kernel = kernel;
                    c_value = -5:1:5;%c_value; 
                    epsilon_value = epsilon_value;
                    gamma_value =  -5:1:5;%gamma_value;
                    [mean_value,var_value,dummy] = 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);
                    rmse_value = rmse_value + dummy;
                end
            end
            k = k + 1;
        end
        j = j + 1;
    end
    rmse_value = rmse_value/n_test_severity_leves;
end
