Returns f-measure.
768939
def fMeasure(self, label, beta=None):
        
        if beta is None:
            return self.call("fMeasure", label)
        else:
            return self.call("fMeasure", label, beta)
19873
def measure_string(self, text, fontname, fontsize, encoding=0):
        """"""
        return _fitz.Tools_measure_string(self, text, fontname, fontsize, encoding)
416955
def results_overall_metrics(self):
        

        # F-measure
        if self.overall['Nref'] > 0:
            precision = metric.precision(
                Ntp=self.overall['Ntp'],
                Nsys=self.overall['Nsys']
            )

            recall = metric.recall(
                Ntp=self.overall['Ntp'],
                Nref=self.overall['Nref']
            )

            f_measure = metric.f_measure(
                precision=precision,
                recall=recall
            )

        else:
            precision = None
            recall = None
            f_measure = None

        y_true = []
        y_score = []
        for tag_id, tag_label in enumerate(self.tag_label_list):
            y_true += self.y_true[tag_label]
            y_score += self.y_pred_score[tag_label]

        if y_score:
            eer = metric.equal_error_rate(
                y_true=y_true,
                y_score=y_score
            )

        else:
            eer = None

        return {
                'count': {
                    'Nref': self.overall['Nref'],
                    'Nsys': self.overall['Nsys'],
                },
                'f_measure': {
                    'f_measure': f_measure,
                    'precision': precision,
                    'recall': recall,
                },
                'eer': {
                    'eer': eer
                }

        }
444484
def Kdiag(self, X):
        """"""
        K_ff = np.zeros(X.shape[0])
        for i,x in enumerate(X):
            K_ff[i] = self.k_ff(x[0],x[0],self.lengthscale[0])
        return K_ff * self.variances[0]
44410
def CallUDFUNS(f, x):
    
    value = c_double()
    f(x, byref(value))
    return value.value
343052
def get_size(self, m):
        
        nrow, ncol = 0, 0
        if m[0] == 'F':
            nrow = self.n
        elif m[0] == 'G':
            nrow = self.m

        if m[1] == 'x':
            ncol = self.n
        elif m[1] == 'y':
            ncol = self.m

        return nrow, ncol
912894
def obfn_dfd(self):
        
        """

        Ef = sl.inner(self.Df, self.obfn_fvarf(), axis=self.cri.axisM) - \
            self.Sf
        return sl.rfl2norm2(Ef, self.S.shape, axis=self.cri.axisN) / 2.0
320734
function getRes(unit) {
      var measured,
          begin,
          count = 30,
          divisor = 1e3,
          ns = timer.ns,
          sample = [];

      // get average smallest measurable time
      while (count--) {
        if (unit == 'us') {
          divisor = 1e6;
          if (ns.stop) {
            ns.start();
            while (!(measured = ns.microseconds())) { }
          } else if (perfName) {
            divisor = 1e3;
            measured = Function('n', 'var r,s=n.' + perfName + '();while(!(r=n.' + perfName + '()-s)){};return r')(ns);
          } else {
            begin = ns();
            while (!(measured = ns() - begin)) { }
          }
        }
        else if (unit == 'ns') {
          divisor = 1e9;
          begin = ns.nanoTime();
          while (!(measured = ns.nanoTime() - begin)) { }
        }
        else {
          begin = new ns;
          while (!(measured = new ns - begin)) { }
        }
        // check for broken timers (nanoTime may have issues)
        // http://alivebutsleepy.srnet.cz/unreliable-system-nanotime/
        if (measured > 0) {
          sample.push(measured);
        } else {
          sample.push(Infinity);
          break;
        }
      }
      // convert to seconds
      return getMean(sample) / divisor;
    }
678616
def fileSize(f):
    ''''''
    offset = f.tell()

    f.seek(0, 2)
    size = f.tell()

    f.seek(offset)  # return to the previous position in the file
    return size
1259953
def count(self, weighted=True):
        """"""
        return self._measures.weighted_n if weighted else self._measures.unweighted_n
1096009
def F(self, x):
        
        if isinstance(x, np.ndarray):
            nfwvals = np.ones_like(x)
            inds1 = np.where(x < 1)
            inds2 = np.where(x > 1)
            nfwvals[inds1] = (1 - x[inds1] ** 2) ** -.5 * np.arctanh((1 - x[inds1] ** 2) ** .5)
            nfwvals[inds2] = (x[inds2] ** 2 - 1) ** -.5 * np.arctan((x[inds2] ** 2 - 1) ** .5)
            return nfwvals

        elif isinstance(x, float) or isinstance(x, int):
            if x == 1:
                return 1
            if x < 1:
                return (1 - x ** 2) ** -.5 * np.arctanh((1 - x ** 2) ** .5)
            else:
                return (x ** 2 - 1) ** -.5 * np.arctan((x ** 2 - 1) ** .5)
556149
def f1_score(self):
        
        m_pre = self.precision()
        rec = self.recall()
        return divide(2.0, 1.0 / m_pre + 1.0 / rec)
1087590
def format_measure(measure):
        """"""
        # Convert to a positive value.
        measure = abs(measure)

        # For number of calls
        if isinstance(measure, int):
            return to_text_string(measure)

        # For time measurements
        if 1.e-9 < measure <= 1.e-6:
            measure = u"{0:.2f} ns".format(measure / 1.e-9)
        elif 1.e-6 < measure <= 1.e-3:
            measure = u"{0:.2f} us".format(measure / 1.e-6)
        elif 1.e-3 < measure <= 1:
            measure = u"{0:.2f} ms".format(measure / 1.e-3)
        elif 1 < measure <= 60:
            measure = u"{0:.2f} sec".format(measure)
        elif 60 < measure <= 3600:
            m, s = divmod(measure, 3600)
            if s > 60:
                m, s = divmod(measure, 60)
                s = to_text_string(s).split(".")[-1]
            measure = u"{0:.0f}.{1:.2s} min".format(m, s)
        else:
            h, m = divmod(measure, 3600)
            if m > 60:
                m /= 60
            measure = u"{0:.0f}h:{1:.0f}min".format(h, m)
        return measure
1165744
def bin_measurement(measurement=None, subsampling_factor=3):
    

    subs = int(subsampling_factor)
    if measurement is None:
        measurement = np.array([])
    n = len(measurement)
    binned_measurement = [measurement[i - subs + 1:i].sum()
                          for i in range(n) if i % subs == 0 and i > 0]
    return np.array(binned_measurement)
1297812
def obfn_fvarf(self):
        

        return self.Xf if self.opt['fEvalX'] else \
            sl.rfftn(self.Y, None, self.cri.axisN)
108202
def obfn_dfd(self):
        
        """

        Ef = sl.inner(self.Zf, self.obfn_fvarf(), axis=self.cri.axisM) \
          - self.Sf
        return (np.linalg.norm(self.W * sl.irfftn(Ef, self.cri.Nv,
                                                  self.cri.axisN))**2) / 2.0
215923
def mean(self):
    """"""
    if len(self) == 0:
      return float('NaN')
    arr = self.samples()
    return sum(arr) / float(len(arr))