Exemple #1
0
import string
import numpy as np

if __name__ == '__main__':
    utils.createDirectory('figure_pair')
    options = utils.getOptions()
    dim     = options['numberOfDimension']

    dataFileName    = utils.getDataFileName(options)
    vpFileName      = utils.getVPFileName(options)
    datas           = utils.getDataInFile(dataFileName)
    vps             = utils.readDataFromFile(vpFileName)

    for i in xrange(len(vps)):
        for j in xrange(i+1,len(vps)):
            cc = utils.calculateCorrelationCoefficient(vps[i],vps[j],datas)
            cc = abs(cc)
            imageFileName = utils.getFigurePairName(options,i,j,cc)
            print imageFileName
            if os.path.exists(imageFileName):
                print '%s is exists'%imageFileName
                continue
            xp = []
            yp = []
            zp = []
            zcnt = [ [ 0 for ii in xrange(dim+1) ] for jj in xrange(dim+1) ]
            for k in xrange(len(datas)):
                x = utils.hammingDistance(vps[i],datas[k])
                y = utils.hammingDistance(vps[j],datas[k])
                zcnt[y][x] = zcnt[y][x] + 1
                xp.append(x)
Exemple #2
0
if __name__ == '__main__':
    options = utils.getOptions()
    dataFileName = 'data/data_%d_%d_%s_%d.txt'%(options['numberOfData'],options['numberOfDimension'],options['distribution'],options['numberOfAlphabet'])
    
    print dataFileName
    datas = utils.getDataInFile(dataFileName)

    filename = utils.getVPFileName(options)
    print filename
    with open(filename,'r') as fp:
        lines = fp.read().rstrip().split('\n')
    vps = []
    for line in lines:
        vps.append(line.rstrip().split(' '))
    cc = []
    for i in xrange(len(vps)):
        for j in xrange(len(vps)):
            if i == j:
                continue
            cc.append(CC(abs(utils.calculateCorrelationCoefficient(vps[i],vps[j],datas)),i,j))
    cc.sort()
    for i in xrange(min(4,len(cc))):
        cur = -(i+1)
        print cc[cur].x, vps[cc[cur].id1], vps[cc[cur].id2]
    print ''
    for i in xrange(min(4,len(cc))):
        cur = i
        print cc[cur].x, vps[cc[cur].id1], vps[cc[cur].id2]
    print ''
Exemple #3
0
import string
import numpy as np

if __name__ == '__main__':
    utils.createDirectory('figure_pair')
    options = utils.getOptions()
    dim = options['numberOfDimension']

    dataFileName = utils.getDataFileName(options)
    vpFileName = utils.getVPFileName(options)
    datas = utils.getDataInFile(dataFileName)
    vps = utils.readDataFromFile(vpFileName)

    for i in xrange(len(vps)):
        for j in xrange(i + 1, len(vps)):
            cc = utils.calculateCorrelationCoefficient(vps[i], vps[j], datas)
            cc = abs(cc)
            imageFileName = utils.getFigurePairName(options, i, j, cc)
            print imageFileName
            if os.path.exists(imageFileName):
                print '%s is exists' % imageFileName
                continue
            xp = []
            yp = []
            zp = []
            zcnt = [[0 for ii in xrange(dim + 1)] for jj in xrange(dim + 1)]
            for k in xrange(len(datas)):
                x = utils.hammingDistance(vps[i], datas[k])
                y = utils.hammingDistance(vps[j], datas[k])
                zcnt[y][x] = zcnt[y][x] + 1
                xp.append(x)