コード例 #1
0
sys.path.append(os.getcwd()[:-5])

from src.timeseries.TimeSeriesLoader import load
from src.transformation.SFA import *

symbols = 8
wordLength = 16
normMean = False


def sfaToWord(word):
    word_string = ""
    for w in word:
        word_string += chr(w + 97)
    return word_string


train, test, train_labels, test_labels = load("CBF", "\t")

sfa = SFA("EQUI_DEPTH")

sfa.fitTransform(train, train_labels, wordLength, symbols, normMean)

sfa.printBins()

for i in range(test.shape[0]):
    wordList = sfa.transform2(test.iloc[i, :], "null")
    print(
        str(i) + "-th transformed time series SFA word " + "\t" +
        sfaToWord(wordList))
コード例 #2
0
    if FIXED_PARAMETERS['test'] == 'Shotgun':
        logger.Log("Test: Shotgun")
        from src.classification.ShotgunClassifier import *
        shotgun = ShotgunClassifier(FIXED_PARAMETERS, logger)
        scoreShotgun = shotgun.eval(train, test)[0]
        logger.Log("%s: %s" % (FIXED_PARAMETERS['dataset'], scoreShotgun))

    ##=========================================================================================
    ## SFA Word Tests
    ##=========================================================================================
    if FIXED_PARAMETERS['test'] == 'SFAWordTest':
        logger.Log("Test: SFAWordTest")
        from src.transformation.SFA import *
        sfa = SFA(FIXED_PARAMETERS["histogram_type"], logger=logger)
        sfa.fitTransform(train, FIXED_PARAMETERS['wordLength'],
                         FIXED_PARAMETERS['symbols'],
                         FIXED_PARAMETERS['normMean'])
        logger.Log(sfa.__dict__)

        for i in range(test["Samples"]):
            wordList = sfa.transform2(test[i].data, "null", str_return=True)
            logger.Log("%s-th transformed TEST time series SFA word \t %s " %
                       (i, wordList))

    if FIXED_PARAMETERS['test'] == 'SFAWordWindowingTest':
        logger.Log("Test: SFAWordWindowingTest")
        from src.transformation.SFA import *

        sfa = SFA(FIXED_PARAMETERS["histogram_type"], logger=logger)
        sfa.fitWindowing(train, FIXED_PARAMETERS['windowLength'],
                         FIXED_PARAMETERS['wordLength'],