% Clear workspace and command window
clear; clc;

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

% Model-1
mse_model1 = [3.6114e-5, 1.8132e-3, 1.2398e-3, 1.5629e-3, 0.99913, 0.99763];

% Model-2
mse_model2 = [1.9214e-5, 2.0911e-3, 3.0683e-3, 1.8762e-3, 0.99845, 0.99678];

% Model-3
mse_model3 = [9.9633e-5, 1.5216e-3, 1.1985e-3, 7.6047e-4, 0.99789, 0.99512];

% Model-4
mse_model4 = [1.3419e-4, 4.1727e-3, 3.3567e-3, 2.3456e-3, 0.99654, 0.99823];

% Colors: PSM (blue), others (distinct colors)
colors = [
    0 0.4470 0.7410;   % 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 = {mse_model1, mse_model2, mse_model3, mse_model4};
titles = {'Model-1', 'Model-2', 'Model-3', 'Model-4'};
ylims = [0.002, 0.004, 0.002, 0.005];

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

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

% Add global title
%sgtitle('Comparison of MSE 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]);