July 2018
Intermediate to advanced
334 pages
8h 20m
English
Here are the lines of code that implement a simple mathematical equation to come up with the precision and recall scores.
Let's calculate precision now:
val precision = tPs / Math.max(1.0, tPs + fPs)
Followed by a calculation of recall:
val recall = tPs / Math.max(1.0, tPs + fNs)
We have both precision and recall. This gives us what we need to calculate the F1 score or the f1Measure, as follows:
val f1Measure = 2.0 * precision * recall / (precision + recall)
Next, let's determine bestErrorTermValue and bestF1measure:
if (f1Measure > bestF1Measure){ bestF1Measure = f1Measure bestErrorTermValue = errorTerm //println("f1Measure > bestF1Measure") scores +( (1, bestErrorTermValue), (2, bestF1Measure) ...Read now
Unlock full access