Beispiel #1
0
def confusion(stims, dm):
    '''
    stims is a tuple of stimulus conditions.

    dm is a distance matrix of responses (with the same number of rows as stims)

    Returns a confusion matrix between stimulus conditions
    '''
    di = infdiag(dm)
    stimind = np.array(stims)
    nstims = stimind.max() + 1
    conf = np.zeros((nstims, nstims))
    for i in range(di.shape[0]):
        inds = np.nonzero(di[i, :] == di[i, :].min())[0]
        st = stimind[inds]
        sst = stimind[i]
        n = 1.0 / inds.shape[0]
        for s in st:
            conf[sst, s] += n
            conf[s, sst] += n
    return conf
Beispiel #2
0
def treeXformAv(evts, q, dmeth):
    dm = infdiag(distance(evts, None, q, dmeth))
    wts = np.ones(dm.shape[0])
    while len(evts) > 2:
        evts, dm, wts = pair_and_av(list(evts), dm, wts, q, dmeth)
    return avst(evts[0], evts[1], q, wts[0], wts[1], dmeth)