Ejemplo n.º 1
0
def _match_sub(disc_clsdict, gold_clsdict, phn_corpus, names, label, verbose,
               n_jobs):
    em = eval_from_psets
    if verbose:
        print '  matching ({2}): subsampled {0} files in {1} sets'\
            .format(sum(map(len, names)), len(names), label)
    with verb_print('  matching ({0}): prepping psets'.format(label), verbose,
                    True, True, True):
        pdiscs = [
            make_pdisc(disc_clsdict.restrict(fs, True), False, False)
            for fs in names
        ]
        pgolds = [
            make_pgold(gold_clsdict.restrict(fs, True), False, False)
            for fs in names
        ]
        psubs = [
            make_psubs(disc_clsdict.restrict(fs, True), phn_corpus, 3, 20,
                       False, False) for fs in names
        ]
    with verb_print('  matching ({0}): calculating scores'.format(label),
                    verbose, False, True, False):
        tp, tr = izip(*Parallel(
            n_jobs=n_jobs, verbose=5 if verbose else 0, pre_dispatch='n_jobs')(
                delayed(em)(pdisc, pgold, psub)
                for pdisc, pgold, psub in zip(pdiscs, pgolds, psubs)))
    tp, tr = np.fromiter(tp, dtype=np.double), np.fromiter(tr, dtype=np.double)
    tp, tr = praggregate(tp, tr)
    return tp, tr
Ejemplo n.º 2
0
def _match_sub(disc_clsdict, gold_clsdict, phn_corpus, names, label,
               verbose, n_jobs):
    em = eval_from_psets
    if verbose:
        print '  matching ({2}): subsampled {0} files in {1} sets'\
            .format(sum(map(len, names)), len(names), label)
    with verb_print('  matching ({0}): prepping psets'.format(label),
                             verbose, True, True, True):
        pdiscs = [make_pdisc(disc_clsdict.restrict(fs, True),
                             False, False)
                  for fs in names]
        pgolds = [make_pgold(gold_clsdict.restrict(fs, True),
                             False, False)
                  for fs in names]
        psubs = [make_psubs(disc_clsdict.restrict(fs, True),
                            phn_corpus, 3, 20, False, False)
                 for fs in names]
    with verb_print('  matching ({0}): calculating scores'
                             .format(label), verbose, False, True, False):
        tp, tr = izip(*Parallel(n_jobs=n_jobs,
                                verbose=5 if verbose else 0,
                                pre_dispatch='n_jobs')
                      (delayed(em)(pdisc, pgold, psub)
                      for pdisc, pgold, psub in zip(pdiscs, pgolds, psubs)))
    tp, tr = np.fromiter(tp, dtype=np.double), np.fromiter(tr, dtype=np.double)
    tp, tr = praggregate(tp, tr)
    return tp, tr