MATLAB Answers

Error using plot Not enough input arguments.

33 views (last 30 days)
Zaime Ali
Zaime Ali on 27 Sep 2020
Commented: Star Strider on 27 Sep 2020
I'm having an issue when plotting recall vs precision
In my code i want to plot a graph to check my faster rcnn accuracy.
My code is below
overlap = 0.5;
[ap, recall, precision] = evaluateDetectionPrecision(resultsDoc, gTestTruth.LabelData(2, :), overlap);
figure;
plot(recall, precision);
grid on
title(sprintf('Average precision = %.1f', ap))
In precision variable i have a value
4×1 cell array
{3×1 double}
{[ 1]}
{[ 1]}
{2×1 double}
In recall variable i have a value
4×1 cell array
{3×1 double}
{[ 0]}
{[ 0]}
{2×1 double}
Now i don't know what to do

  0 Comments

Sign in to comment.

Answers (2)

the cyclist
the cyclist on 27 Sep 2020
If you take a look at the documentation for the plot function, you will see that it cannot take cell arrays as input.
I'm not exactly sure what you are trying to plot, but maybe you need to pull out the contents of the cell array to plot? Possibly something like
plot(recall{1},precision{1})

  3 Comments

Zaime Ali
Zaime Ali on 27 Sep 2020
I want to plot the accuracy of my model by passing the gtruth and result
resultsDoc = table('Size', [1, 3], ...
'VariableTypes',{'cell', 'cell', 'cell'},...
'VariableNames',{'Boxes', 'Scores', 'Labels'}...
);
img = imread('dataset/img_7.jpg');
GS = imresize(img, [400 450]);
[bbox, score, label] = detect(fasterRcnn, GS, 'Threshold', 0.85);
[selectedBbox , selectedScore, selectedLabels] = selectStrongestBboxMulticlass(bbox, score , label, ...
'OverlapThreshold', 0.1);
resultsDoc.Boxes{1} = selectedBbox;
resultsDoc.Scores{1} = selectedScore;
resultsDoc.Labels{1} = selectedLabels;
overlap = 0.5;
[ap, recall, precision] = evaluateDetectionPrecision(resultsDoc, gTestTruth.LabelData(2, :), overlap);
figure;
plot(recall, precision);
grid on
title(sprintf('Average precision = %.1f', ap))
Zaime Ali
Zaime Ali on 27 Sep 2020
I have also tried your solution but it's giving me a straight line now
the cyclist
the cyclist on 27 Sep 2020
To be clear, all I was really trying to do was point out that you were using MATLAB syntax incorrectly. You did not post enough information to do much more than that.
I strongly suggest you do more than just "try a solution" posted here. You need to
  • think carefully about what you want your code to do conceptually -- in your case, plotting the accuracy
  • learn/understand the MATLAB functions that can accomplish that
  • form your data into the proper form of input for those functions
  • repeat the above if you do not get what you expect
We can help with some of that, but it is really important for to think about our suggestions, and understand how they help solve your problem.

Sign in to comment.


Star Strider
Star Strider on 27 Sep 2020
You may need to use the cell2mat function, or concatenate the elements inside a vector, using this (strange-looking but effective) notation:
plot([recall{:}], [precision{:}])
.

  2 Comments

Zaime Ali
Zaime Ali on 27 Sep 2020
when using cell2mat function, it is plotting the horizontal line on y-index
Star Strider
Star Strider on 27 Sep 2020
Use the other option, cell2mat instead:
recallv = cell2mat(recall);
precisionv = cell2mat(precision);
When I tested them with:
recall = {rand(3,1); 1; 1; rand(2,1)};
precision = {rand(3,1); 0; 0; rand(2,1)};
cell2mat worked correctly.
Then:
figure
plot(recallv, precisionv)
grid
title(sprintf('Average precision = %.1f', ap))
should produce the plot you want.
That plots correctly for me. It is plotting a horizontal line, look at the result of the cell2mat output. That is likely what your data actually are, such that ‘precision’ is essentially a constant for all values of ‘recall’. I do not have your data, so I cannot determine that.

Sign in to comment.

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by