if __name__ == '__main__': 

    # global parameters for distance measures (Manhatten/Euclidean, sym. gem)
    squared, symmetric = True, True

    # read dataset number and split number
    try:
        datasetN, splitN = int(sys.argv[1]), int(sys.argv[2])
    except:
        raise Exception \
             ("python2 1NNResampledTest.py datasetnumber(int) splitnumber(int)")
    
    # read the dataset
    (testLabels, testSet), (trainLabels, trainSet)  = ucr.read(datasetN)
    # merge dataset
    labels, items = ucr.merge(testLabels, testSet, trainLabels, trainSet)
    
    # open file for the logging of results
    f = open("./results/dn_%s-sn_%s-sq_%s-sy_%s" % 
            (datasetN, splitN, squared, symmetric), "w")
    
    # if splitN == 0 use UCR-split else use random split
    if splitN > 0:

        # determine split ratio from UCR canonical split and resample
        rho = float(len(trainSet))/(len(trainSet)+len(testSet))
        sss = st.StratifiedShuffleSplit(labels, 500, 
                                        test_size=rho, random_state=0)
        test_index, train_index = list(sss)[splitN-1]
        
        # create training and test set
Exemple #2
0
if __name__ == '__main__':

    # global parameters for distance measures (Manhatten/Euclidean, sym. gem)
    squared, symmetric = True, True

    # read dataset number and split number
    try:
        datasetN, splitN = int(sys.argv[1]), int(sys.argv[2])
    except:
        raise Exception \
             ("python2 1NNResampledTest.py datasetnumber(int) splitnumber(int)")

    # read the dataset
    (testLabels, testSet), (trainLabels, trainSet) = ucr.read(datasetN)
    # merge dataset
    labels, items = ucr.merge(testLabels, testSet, trainLabels, trainSet)

    # open file for the logging of results
    f = open(
        "./results/dn_%s-sn_%s-sq_%s-sy_%s" %
        (datasetN, splitN, squared, symmetric), "w")

    # if splitN == 0 use UCR-split else use random split
    if splitN > 0:

        # determine split ratio from UCR canonical split and resample
        rho = float(len(trainSet)) / (len(trainSet) + len(testSet))
        sss = st.StratifiedShuffleSplit(labels,
                                        500,
                                        test_size=rho,
                                        random_state=0)