% Returns harmonic mean of precision and recall.  Intended to be used
% with breakeven.m
%
% Written by Jason Rennie, February 2004
% Last modified: Tue Dec 13 10:16:14 2005

function [obj] = f1(np,nn,fp,fn)
  recall = (np-fn)/np;
  if fp+np-fn > 0
    precision = (np-fn)/(fp+np-fn);
  else
    precision = 0;
  end
  if precision+recall > 0
    obj = 2*recall*precision/(recall+precision);
  else
    obj = 0;
  end

