def calcDistMetric(r, m):
    if ((r[0] == 0) and (m[0] == 0)) or ((r[0] == 1) and (m[0] == 1)):
        return 0.0
    else:
        # get initial states
        rI = initialState(r)
        mI = initialState(m)

        dists = []
        for a in actionList:
            oR, rI = transExternal.simulate(rI, a)
            oM, mI = transExternal.simulate(mI, a)
            dists.append(distOs(oR, oM))

        return np.mean(dists)
def calcDistMetric(r,m):
    if ((r[0] == 0) and (m[0] == 0)) or ((r[0] == 1) and (m[0] == 1)):
        return 0.0
    else:
        # get initial states
        rI = initialState(r)
        mI = initialState(m)
        
        dists = []
        for a in actionList:
            oR,rI = transExternal.simulate(rI,a)
            oM,mI = transExternal.simulate(mI,a)
            dists.append(distOs(oR,oM))
            
        return np.mean(dists)
Пример #3
0
            misClass[rAll[-1][0]] += 1
            misClassMT[rAll[-1][0]][mAll[-1][0]] += 1

        # and
        # calculate distance metric for every step
        for r, m in zip(rAll, mAll):
            if ((r[0] == 0) and (m[0] == 0)) or ((r[0] == 1) and (m[0] == 1)):
                errors[rAll[-1][0]][-1].append(0)
            else:
                # get initial states
                rI = initialState(r)
                mI = initialState(m)

                dists = []
                for a in actionList:
                    oR, rI = transExternal.simulate(rI, a)
                    oM, mI = transExternal.simulate(mI, a)
                    dists.append(distOs(oR, oM))

                errors[rAll[-1][0]][-1].append(np.mean(dists))

else:
    # iterate over states
    for i, (rAll, mAll) in enumerate(zip(rStatesSave, mStatesSave)):
        print i
        # check for misclassification
        if rAll[-1][0] != mAll[-1][0]:
            # misclassified
            misClass[rAll[-1][0]] += 1
            misClassMT[rAll[-1][0]][mAll[-1][0]] += 1
        else:
            misClass[rAll[-1][0]] += 1
            misClassMT[rAll[-1][0]][mAll[-1][0]] += 1

        # and
        # calculate distance metric for every step
        for r,m in zip(rAll,mAll):
            if ((r[0] == 0) and (m[0] == 0)) or ((r[0] == 1) and (m[0] == 1)):
                errors[rAll[-1][0]][-1].append(0)
            else:
                # get initial states
                rI = initialState(r)
                mI = initialState(m)

                dists = []
                for a in actionList:
                    oR,rI = transExternal.simulate(rI,a)
                    oM,mI = transExternal.simulate(mI,a)
                    dists.append(distOs(oR,oM))

                errors[rAll[-1][0]][-1].append(np.mean(dists))

else:
    # iterate over states
    for i,(rAll,mAll) in enumerate(zip(rStatesSave,mStatesSave)):
        print i
        # check for misclassification
        if rAll[-1][0] != mAll[-1][0]:
            # misclassified
            misClass[rAll[-1][0]] += 1
            misClassMT[rAll[-1][0]][mAll[-1][0]] += 1
        else: