% Clear workspace and command window
clear; clc;

% Extract R-values for Valid data from the four models
models = {'PSM', 'DNN-GD', 'DNN-GDM', 'DNN-GDA', 'SVM', 'KNN'};

% Model-1
r_model1 = [0.99863, 0.95556, 0.961, 0.94998, 0.99576, 0.99616];

% Model-2
r_model2 = [0.99919, 0.89625, 0.95983, 0.97233, 0.99669, 0.99198];

% Model-3
r_model3 = [0.99095, 0.96152, 0.88123, 0.97842, 0.98452, 0.94305];

% Model-4
r_model4 = [0.99758, 0.94794, 0.95296, 0.94439, 0.99452, 0.9197];

% Colors: PSM (blue), others (distinct colors)
colors = [
    0 0 1;               % Blue for PSM
    0.8500 0.3250 0.0980; % Red-orange
    0.9290 0.6940 0.1250; % Yellow
    0.4940 0.1840 0.5560; % Purple
    0.4660 0.6740 0.1880; % Green
    0.3010 0.7450 0.9330; % Cyan
];

% Create figure
figure('Position', [100, 100, 1000, 800]);

% Data and titles for plotting
model_data = {r_model1, r_model2, r_model3, r_model4};
titles = {'Model-1', 'Model-2', 'Model-3', 'Model-4'};
ylims = [0.85, 1.0];

for i = 1:4
    subplot(2,2,i);
    h = bar(model_data{i}, 'FaceColor', 'flat');
    title(['R-value for Valid Data - ' titles{i}], 'FontName', 'Times New Roman', 'FontSize', 16);
    xlabel('Models', 'FontName', 'Times New Roman', 'FontSize', 16);
    ylabel('R-value', 'FontName', 'Times New Roman', 'FontSize', 16);
    set(gca, 'XTick', 1:length(models), 'XTickLabel', models, 'FontName', 'Times New Roman', 'FontSize', 14);
    ylim(ylims);
    grid on;

    % Assign distinct colors
    for j = 1:length(models)
        h.CData(j,:) = colors(j,:);
    end
end

% Add global title
%sgtitle('Comparison of R-values for Valid Data Across Models', 'FontName', 'Times New Roman', 'FontSize', 18);

% Display current date and time
current_time = datestr(now, 'HH:MM PM +07 on dddd, mmmm dd, yyyy');
disp(['Generated at: ' current_time]);