Exemplo n.º 1
0
    f.close()
else:
    f = open(outFile, 'r')
    sSave = json.load(f)
    rStatesSave = sSave['rStatesSave']
    mStatesSave = sSave['mStatesSave']
    f.close()

    print len(rStatesSave)
    print len(mStatesSave)

    for i in range(numET):
        for j in range(numMT):
            for k in range(numT):
                sInd = numMT * numT * i + numT * j + k
                e = auxUtils.stateDist2(rStatesSave[sInd], mStatesSave[sInd])
                if e < 1000:
                    errors[i][j].append(e)
                else:
                    misClass[i][j] += 1
                    misClassMT[i][j][relevantMT.index(
                        mStatesSave[sInd][0])] += 1
                    print "This is a huge ERROR!"
                #print rStatesSave[sInd]
                #print mStatesSave[sInd]
                #print auxUtils.stateDist2(rStatesSave[sInd],
                #                          mStatesSave[sInd])

raise Exception
print errors
                # find max state
                maxProbs = []
                maxProbInds = []
                for l in relevantMT:
                    maxProbs.append(max(logProbs[-1][l]))
                    maxProbInds.append(logProbs[-1][l].index(maxProbs[-1]))

                maxModelInd = maxProbs.index(max(maxProbs))
                maxProbInd = maxProbInds[maxModelInd]
                maxState = states[-1][relevantMT[maxModelInd]][maxProbInd]

                print realStates[-1]
                print maxState
                rStatesSave.append(realStates[-1])
                mStatesSave.append(maxState)
                errors[i][j].append(auxUtils.stateDist2(realStates[-1], maxState))

    f = open(outFile, "w")
    json.dump({"rStatesSave": rStatesSave, "mStatesSave": mStatesSave}, f)
    f.close()
else:
    f = open(outFile, "r")
    sSave = json.load(f)
    rStatesSave = sSave["rStatesSave"]
    mStatesSave = sSave["mStatesSave"]
    f.close()

    print len(rStatesSave)
    print len(mStatesSave)

    for i in range(numET):
    f.close()
else:
    f = open(outFile,'r')
    sSave = json.load(f)
    rStatesSave = sSave['rStatesSave']
    mStatesSave = sSave['mStatesSave']
    f.close()

    print len(rStatesSave)
    print len(mStatesSave)

    for i in range(numET):
        for j in range(numMT):
            for k in range(numT):
                sInd = numMT*numT*i+numT*j+k
                e=auxUtils.stateDist2(rStatesSave[sInd],
                                      mStatesSave[sInd])
                if e<1000:
                    errors[i][j].append(e)
                else:
                    misClass[i][j]+=1
                    misClassMT[i][j][relevantMT.index(mStatesSave[sInd][0])]+=1
                    print "This is a huge ERROR!"
                #print rStatesSave[sInd]
                #print mStatesSave[sInd]
                #print auxUtils.stateDist2(rStatesSave[sInd],
                #                          mStatesSave[sInd])

raise Exception
print errors

                maxProbs = []
                maxProbInds = []
                for l in relevantMT:
                    maxProbs.append(max(logProbs[-1][l]))
                    maxProbInds.append(logProbs[-1][l].index(maxProbs[-1]))

                maxModelInd = maxProbs.index(max(maxProbs))
                maxProbInd = maxProbInds[maxModelInd]
                maxState = states[-1][relevantMT[maxModelInd]][maxProbInd]

                print realStates[-1]
                print maxState
                rStatesSave.append(realStates[-1])
                mStatesSave.append(maxState)
                errors[i][j].append(
                    auxUtils.stateDist2(realStates[-1], maxState))

    f = open(outFile, 'w')
    json.dump({'rStatesSave': rStatesSave, 'mStatesSave': mStatesSave}, f)
    f.close()
else:
    f = open(outFile, 'r')
    sSave = json.load(f)
    rStatesSave = sSave['rStatesSave']
    mStatesSave = sSave['mStatesSave']
    f.close()

    print len(rStatesSave)
    print len(mStatesSave)

    for i in range(numET):