Ejemplo n.º 1
0
def main(): #main function for display and various values of s
    k,m,p = parseone()
    rawdata,rawwholedata = parsetwo()
    
    f = open('sxv146930.txt' ,'w')
    f.write('\n')
    
    for s in range(1,6):
        finaldata, E, sigma = computepermutation(k, m, p, s, rawdata)
        outdata = deconvertdata(finaldata)
        wholedata = Algorithm.dots(rawwholedata,s)
        wholedata.update(outdata)
        f.write('K-NN = ' + str(s))
        f.write(' E = ' + str(E))
        f.write(' SIGMA = ' + str(sigma))
        f.write('\n')
        
        print_matrix = {}
        for thing in wholedata:
            x2, x1, pred = wholedata[thing][0], wholedata[thing][1], wholedata[thing][2]
            if x1 not in print_matrix:
                print_matrix[x1] = {}
            print_matrix[x1][x2] = pred

        for key in sorted(print_matrix.keys()):
            f.write (' '.join([print_matrix[key][i] for i in sorted(print_matrix[key].keys())])+'\n')
        
        f.write('\n')
Ejemplo n.º 2
0
def order(p): #define the order according to permutation
    data,wholedata = parsetwo()
    currdata=data.keys()
    neworder = [currdata[i] for i in p]
    return OrderedDict((key, data[key]) for key in neworder)