How to use ROC FUNCTION in MATLAB
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
balandong
el 12 de Ag. de 2017
Comentada: balandong
el 13 de Ag. de 2017
Dear Matlab user, I have difficulties in applying the ROC FUNCTION. Let have the discussion by having a simple example.
Assume, we have the true condition and predicted condition represent by the vector actual and predicted, respectively.
actual = [1;1;1;1;1;1;1;0;0;0]; % targets
predicted = [1;1;1;1;1;0;0;1;0;0]; % outputs.
Manual calculate the True positive rate (FPR) and false positive rate (FPR) yield 5/7 and 1/3, respectively. The figure below show the confusion matrix and the calculation
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/166675/image.jpeg)
However, by using the ROC FUNCTION, MATLAB give 1x10 and 1x10 instead of a single value for each of the TPR and FPR (i.e., 5/7 & 1/3).
[tpr,fpr,th] = roc(actual,predicted);
In this case, I thing I have misunderstood the usage of ROC function. I really appreciate if someone can show what and how to use the ROC function, correctly
Thanks in advance.
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Ag. de 2017
They apparently need to be row vectors. (I found the documentation a bit confusing, but then I do not use these functions frequently.)
[tpr,fpr,th] = roc(actual',predicted')
and using format rat, produces:
tpr =
0 5/7
fpr =
0 1/3
th =
1 0
7 comentarios
Star Strider
el 12 de Ag. de 2017
I am having a very difficult time reconciling the information you are giving the roc function with the documentation for it. The ‘actual’ and ‘predicted’ matrices need to be the same size. This may be the reason you are having problems with it.
Please run the ‘iris data’ demo code in the roc dicumentation to see what the function expects.
Más respuestas (0)
Ver también
Categorías
Más información sobre Detection en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!