コード例 #1
0

if __name__ == '__main__': 

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

    # read split number
    try:
        splitN, splitL = int(sys.argv[1]), int(sys.argv[2])
    except:
        raise Exception \
              ("python2 MetalError.py splitnumber(int) splitlearn(int)")

    # read data from database
    (parentLabels, parent), (childLabels, child) = mdb.read()
    print "done reading metal data"

    # downsample time series to 1024 points to reduce computational complexity
    parent = map(lambda series: mdb.scale(series, length=2**10), parent)
    child = map(lambda series: mdb.scale(series, length=2**10), child)
    print "done with the scaling"

    # znormalize data for all distance measures but gem
    zparent = map(mdb.znormalize, parent)
    zchild = map(mdb.znormalize, child)

    # open file for the logging of results
    f = open("./results/dn_M-sn_%s-lp_%s-sq_%s-sy_%s" % 
            (splitN, splitL, squared, symmetric), "w")
    
コード例 #2
0
    """concatenate a bunch of time series"""

    return np.hstack(tuple(listOfSeries))

def extract(subject, length):
    """extract a subsequence from subject"""
    
    # get left position of extraction window
    left = np.random.uniform(0, len(subject)-length-1)
    
    return subject[left:left+length]

if __name__ == '__main__': 

    # read data from database
    (parentLabels, parent), (childLabels, child) = mdb.read()
    print "done reading metal data"
    
    # read length
    try:
        L, N  = int(sys.argv[1]), int(sys.argv[2])
    except:
        raise Exception \
              ("python2 QueryAndSubjectGeneratorMetall.py L(int) N(int)")
    
    # for reproducibility
    np.random.seed(L)
    
    # concatenate database
    subject, queries = cat(parent), cat(child)
    
コード例 #3
0
import numpy as np
import pylab as pl
import scipy.cluster.hierarchy as h
import utils.distances as ds
import utils.MetalDatabase as mdb

# read data from database
(parentLabels, parent), (childLabels, child) = mdb.read()
print "done reading metal data"

# downsample time series to 1024 points to reduce computational complexity
parent = map(lambda series: mdb.scale(series, length=2**10), parent)
child = map(lambda series: mdb.scale(series, length=2**10), child)
print "done with the scaling"

# znormalize data for all distance measures but gem
zparent = map(mdb.znormalize, parent)
zchild = map(mdb.znormalize, child)

# taken from dn_M-sn_0-lp_100-sq_True-sy_True LISTCONSDTWONE
mask = [
    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
    0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0,
    0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
    1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
    0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
    1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,