# F-measure for document clustering evaluation - NaN

I'm developing the Java application for text document clustering, and I'm researching some evaluation methods. I implemented F-measure (http://en.wikipedia.org/wiki/F1_score), but I have a problem - the returned value is NaN. It happens where a cluster doesn't contain any data from a specific category - precision and recall are equal to zero. How should I handle this situation - F-measure in that case should be zero as well? I will be very grateful for any advice.

Long answer: In a rigorous mathematical sense, the F1-score is defined such that if the precision and recall are both zero, the F1-score is undefined: $$F1=2\cdot\frac{precision \cdot recall}{precision+recall}.$$
You could perhaps justify setting F1 to zero by arguing that you are only sampling the true population and as precision and recall approach a small value, $\epsilon$, the numerator approaches zero faster than the denominator since it goes like $\frac{\epsilon^{2}}{\epsilon}=\epsilon$~0.