How do I include errorbar on my F1 score plot

I want to include the errorbar on my F1 score plot. I don't know how to go about it. Here is my code below
% Given data
p = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
TPR_PCA = [79.4, 80.25, 83, 90.50, 91.31, 91.34, 91.34, 91.35, 91.35, 91.35] / 100;
TPR_kPCA = [80.50, 81.70, 85.85, 92.25, 92.40, 92.45, 92.44, 92.48, 92.50, 92.50] / 100;
PREC_PCA = [71.05, 72.50, 76.70, 86.00, 86.20, 86.20, 86.25, 86.27, 86.27, 86.28] / 100;
PREC_kPCA = [72.20, 73.00, 78.95, 88.40, 88.56, 88.56, 88.56, 88.56, 88.56, 88.56] / 100;
% Compute F1 scores for PCA-HMM and kPCA-HMM
F1_PCA = 2 * (TPR_PCA .* PREC_PCA) ./ (TPR_PCA + PREC_PCA);
F1_kPCA = 2 * (TPR_kPCA .* PREC_kPCA) ./ (TPR_kPCA + PREC_kPCA);
figure;
subplot(1,2,1) %SRW
plot(p, F1_PCA, 'kx-', 'MarkerSize', 8, 'DisplayName', 'SRW:PCA-HMM');
hold on;
plot(p, F1_kPCA, 'mo-', 'MarkerSize', 5, 'DisplayName', 'SRW:kPCA-HMM');
hold off;
xlabel('p');
ylabel('F1 Score');
title('\textbf{(a) F1 score @ $\mathcal{W}$=128}', 'Interpreter','latex');
legend('Location', 'southeast');
grid minor;

Réponses (1)

Use errorbar -
% Given data
p = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
TPR_PCA = [79.4, 80.25, 83, 90.50, 91.31, 91.34, 91.34, 91.35, 91.35, 91.35] / 100;
TPR_kPCA = [80.50, 81.70, 85.85, 92.25, 92.40, 92.45, 92.44, 92.48, 92.50, 92.50] / 100;
PREC_PCA = [71.05, 72.50, 76.70, 86.00, 86.20, 86.20, 86.25, 86.27, 86.27, 86.28] / 100;
PREC_kPCA = [72.20, 73.00, 78.95, 88.40, 88.56, 88.56, 88.56, 88.56, 88.56, 88.56] / 100;
% Compute F1 scores for PCA-HMM and kPCA-HMM
F1_PCA = 2 * (TPR_PCA .* PREC_PCA) ./ (TPR_PCA + PREC_PCA);
F1_kPCA = 2 * (TPR_kPCA .* PREC_kPCA) ./ (TPR_kPCA + PREC_kPCA);
%Size of the error bar you want
err = 0.005*ones(size(p));
figure;
errorbar(p, F1_PCA, err, 'kx-', 'MarkerSize', 8, 'DisplayName', 'SRW:PCA-HMM');
hold on;
errorbar(p, F1_kPCA, err, 'mo-', 'MarkerSize', 5, 'DisplayName', 'SRW:kPCA-HMM');
hold off;
xlabel('p');
ylabel('F1 Score');
title('\textbf{(a) F1 score @ $\mathcal{W}$=128}', 'Interpreter','latex');
legend('Location', 'southeast');
grid minor;
xlim([2 13])

3 commentaires

Cutie
Cutie le 29 Août 2023
Thank you @Dyuman Joshi but this does not show the relationship between the two metrics as regards the error bar. I want the error bar of the two metric (PCA & kPCA) to be unto one another in order to assess the relationship
Dyuman Joshi
Dyuman Joshi le 29 Août 2023
I don't understand.
Could you please show an example or specify more about what you want to obtain?
Cutie
Cutie le 29 Août 2023
Modifié(e) : Cutie le 30 Août 2023
Thank you again @Dyuman Joshi
I have developed two models, PCA-HMM and kPCA-HMM. I have computed the F1 score for the two models on the same plot. Now, I want to use the error bar to evaluate conficen interval (or assess the level of confidence) in my results and how the error bars can be used to gain more insight about the results.

Connectez-vous pour commenter.

Catégories

Produits

Version

R2021b

Question posée :

le 29 Août 2023

Modifié(e) :

le 30 Août 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by