How calculate a true negatives in my case (to make a ROC analisys)?

2 Ansichten (letzte 30 Tage)
Nik Rocky
Nik Rocky am 21 Jun. 2020
Kommentiert: Nik Rocky am 21 Jun. 2020
Hello together,
I have a motor that rotating in a light gate and producing a ground truth "G"
A microphone that take an audio capture of this motor.
An algorithm, analyze this audio capture and detect a ground truth (F0/F1) in spectrum "R"
I calculate a TP/FN/FP with (pseudo code):
if R is element from G-array ​% right motorspeed detected
than TP = TP + 1;
if R is not element from G-array​ % wrong motorspeed detected
than FP = FP + 1;
if G not element from R-array​ %motorspeed is not detected
than FN = FN + 1;
end
with a code (in a loop):
motor_actual = nonzeros(unique(motor_actual)); %No zeros no repeats
motorspeed_detected = nonzeros(unique(motorspeed_detected)); %No zeros no repeats
Analyse1 = ismembertol(motorspeed_detected, motor_actual*harm, tube_cnt, 'DataScale' , 1); %Elements of R in G +-tolerance
Analyse2 = ismembertol(motor_actual*harm, motorspeed_detected, tube_cnt, 'DataScale' , 1); %Elements of G in R +-tolerance
TP_help = nnz(Analyse1); %right frequency detected
FP_help = nnz(~Analyse1); %wrong frequency detected
FN_help = nnz(~Analyse2); %no frequency detected
TP = TP + TP_help;
FP = FP + FP_help;
FN = FN + FN_help;
Now, I have to create a receiver operating characteristic curve (ROC curve).
To do this I need a true positive rate: TP_rate = TP/(TP+FN) and false positive rate: FP_rate = FP/(FP+TN)
So, I need also to calculate TN!
The condition for TM is:
if R is element from G-array ​== 0 %right motor stop detecting
TN = TN + 1;
end
But how is this possible, when:
1. my motor is always on, so ground truth G is > 0
2. algorithm can detect just positive values R > 0
So, TN = 0?
So I have always FP_rate = FP/(FP+0) = 1?
Or I can use another method to find a FP_Rate?
Thank you in advice!
  4 Kommentare
KALYAN ACHARJYA
KALYAN ACHARJYA am 21 Jun. 2020
Sorry not getting the exact logic. Is this "producing a ground truth "G"? Ground truth for the comparison, whether the code classify the right or wrong.
Nik Rocky
Nik Rocky am 21 Jun. 2020
Hi Kalyan,
ground truth G have a values of a real speed of motors
G =
0 60,1
0,1 60
0,2 60,5
0,3 60,15
0,4 60
.......
29,9 61,1
30 60,54
first column is time, second a real rotating speed (ground truth)
R have a detected speed via algorithm:
R =
0 60
0,1 59
0,3 60,28
0,4 61
0,8 74,28
1 60
1,1 60
.......
29,9 61,1
30 60
first column is time, second a detected speed from audio spectrum

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by