Exemple #1
0
    secondTS = time.time()
    timestamps["load" + str(i)] = secondTS - firstTS
# training CE using the added data, while the training time is measured
firstTS = time.time()
algorithmTest.clusterAndTrain()
secondTS = time.time()
timestamps["train"] = secondTS - firstTS
print "Done: loading and training"
print "Beginning execution"
runningTotal = 0

for executeSample in range(testRecStop - testRecStart + 1):
    # computing output of test data using trained CE (time measured)
    # Saving error for each test data.
    firstTS = time.time()
    algoRes = algorithmTest.deNormalizeSnippet(
        algorithmTest.executeAndCluster(list(inDataTest[executeSample])), -1)
    secondTS = time.time()
    timestamps["test" + str(executeSample)] = secondTS - firstTS
    timestamps["delta" + str(executeSample)] = \
            abs(np.asarray(algorithmTest.deNormalizeSnippet(\
                algorithmTest.classify(\
                algorithmTest.normalizeSnippet(\
                outDataTest[executeSample], -1), -1), -1))\
                - np.asarray(algoRes))
    if printFlag == True:
        print algorithmTest.deNormalizeSnippet(\
            algorithmTest.classify(\
            algorithmTest.normalizeSnippet(\
            outDataTest[executeSample], -1), -1), -1), \
            algoRes
    runningTotal += outDataTest[executeSample]
    secondTS = time.time()
    timestamps["load" + str(i)] = secondTS - firstTS
# training CE using the added data, while the training time is measured
firstTS = time.time()
algorithmTest.clusterAndTrain()
secondTS = time.time()
timestamps["train"] = secondTS - firstTS
print "Done: loading and training"
print "Beginning execution"
runningTotal = 0

for executeSample in range(testRecStop - testRecStart + 1):
    # computing output of test data using trained CE (time measured)
    # Saving error for each test data.
    firstTS = time.time()
    algoRes = algorithmTest.deNormalizeSnippet(
            algorithmTest.executeAndCluster(list(inDataTest[executeSample])),-1)
    secondTS = time.time() 
    timestamps["test" + str(executeSample)] = secondTS - firstTS
    timestamps["delta" + str(executeSample)] = \
            abs(np.asarray(algorithmTest.deNormalizeSnippet(\
                algorithmTest.classify(\
                algorithmTest.normalizeSnippet(\
                outDataTest[executeSample], -1), -1), -1))\
                - np.asarray(algoRes))
    if printFlag == True:
        print algorithmTest.deNormalizeSnippet(\
            algorithmTest.classify(\
            algorithmTest.normalizeSnippet(\
            outDataTest[executeSample], -1), -1), -1), \
            algoRes
    runningTotal += outDataTest[executeSample]