All right.
So now that we've established that there is an inverse relationship between the precision school and
recall we'll need a way to reconcile the two because ideally you want both high precision and high recall.
The good news is that both of these metrics can be blended into a single value which is called the f
score also known as the f one score.
Here's the definition the f score is defined as two times precision times recall divided by precision
plus recall so what this formula is telling us is that we want to create a balanced classifier.
We try and maximize the f1 score let's head over to Jupiter notebook and calculate this I'll insert
a quick section hitting him hold f hyphen school or F one school and here I'll calculate the value f
1 underscore.
Score is equal to well what do we say two times and then I'll be precision on a score score times recall
on the score score all divided by precision on a score score plus recall underscore score and if we
want to print this out c f score is and then curly braces colon C I don't know to dot format parentheses
F one and a score score and before I hit shift enter I'll put a decimal point here and what we get is
the f score is equal to zero point nine five which actually is very very good but how do we interpret
the F school what does it mean well.
So technically speaking the f score is the harmonic average the harmonic mean of precision and recall
and because of this it takes both the false positives and the false negatives into account also it always
has a value between 0 and 1.
So 1 is the maximum value which is why zero point nine five is very very high and zero is the minimum
value so in conclusion we've done a lot of evaluation on our need based classifier we've looked at a
number of metrics precision recall f score and accuracy and we're doing actually very very very well
because the number of false positives and false negatives is very low given the amount of data that
we have now.
Of course our spam filter isn't perfect right.
I mean spam filters these days are actually getting really really good right because they don't just
look at the words in the email body they actually look at a lot of other things as well write that a
spammer might do for example a spammer might falsify the header or always send spam from like the same
IP address which is why there are IP blacklists so truth be told I'm actually always really really impressed
when a spammer manages to inbox in my gmail or in my hotmail account I'm almost always tempted to actually
reply like Hey how did you manage to get around the spam filter and get into my inbox tell me your secrets
but that's probably just going to net me a lot more spam but I think we've come very very far and you
really deserve a big big pat on the back if you've completed all of this and made it through all of
this and understood it this was a very very involved and a very very big project but we've touched on
many many areas of machine learning and data science and we were able to learn a lot of these concepts
as they came up as we needed them as part of this project so again well done and I'll see you in the
next lesson as always take her.