Exemple #1
0
    from pylab import text,show,cm,axis,figure,subplot,imshow,zeros
    figure(1)
    im = 0
    result = np.array([])
    for x,t in zip(data,num): # scatterplot
     w = drmap.winner(x)
     result.resize((im+1,3))
     result[im][0]=w[0]
     result[im][1]=w[1]
     result[im][2]=num[im]
     text(w[0]+.5, w[1]+.5, str(t), color=cm.Dark2(t / 8.), fontdict={'weight': 'bold', 'size': 11})
     im = im + 1
     axis([0,drmap.weights.shape[0],0,drmap.weights.shape[1]])

    # Save SOM file
    drmap.save_map()

else:
    if mode == 2:
        print "Using LLE"
        construct = manifold.LocallyLinearEmbedding(n_neighbors, n_components=2, method='standard')
        if fresh_data == 1:
            print "Training..."
            drmap = construct.fit(data)
            print "\n...ready!"
            f = open('LLE','w')
            pickle.dump(drmap,f)
            f.close()
        else:
            print "Loading Data"
            f = open('LLE', 'r')