def main():
    filenm = "surf3"
    # tsne_x,X_Ids = TSNE_Surf(filenm)
    Tsne, ids = tsneHandler.getTSNEwithIds(filenm)
    img = plot_visualisation.plot_raw_TSNE(Tsne, ids, filenm)
    # img = cv2.imread(dirm.outputDirectory+"surf3.jpg")
    plot_visualisation.displayInteractiveImage(img, "surf3")
def main():
    filenm = "surf3"
    #tsne_x,X_Ids = TSNE_Surf(filenm)
    Tsne, ids = tsneHandler.getTSNEwithIds(filenm)
    img = plot_visualisation.plot_raw_TSNE(Tsne, ids, filenm)
    #img = cv2.imread(dirm.outputDirectory+"surf3.jpg")
    plot_visualisation.displayInteractiveImage(img, "surf3")
def Kmenas_General(tablename):
    conn = sqlite3.connect(dirm.sqlite_file)
    c = conn.cursor()
    cmd = 'SELECT * FROM {tn}'.format(tn=tablename)
    c.execute(cmd)
    all_rows = c.fetchall()
    ids = []
    data = []
    for row in all_rows:
        ids.append(str(row[0]))
        data.append(row[1:])
    X = np.array(data)

    estimators = {
        'k_means_3': KMeans(n_clusters=3),
        'k_means_5': KMeans(n_clusters=3),
        'k_means_8': KMeans(n_clusters=8)
    }

    est = KMeans(n_clusters=3)
    est.fit(X)
    labels = est.labels_
    labels_np = np.array(labels)
    results = []
    tsne_vals, ids2 = tsneHandler.getTSNEwithIds(tablename)
    tsne_x, tsne_y = zip(*tsne_vals)
    results = zip(ids, ids2, tsne_x, tsne_y, labels_np)
    #header = ('id','id2','tsne_x','tsne_y','lables')
    #results_w_header = header + results
    #print results_w_header
    util.writetoCSV(results, tablename + "_clustered")
def Kmenas_General(tablename):
    conn = sqlite3.connect(dirm.sqlite_file)
    c = conn.cursor()
    cmd = 'SELECT * FROM {tn}'.format(tn=tablename)
    c.execute(cmd)
    all_rows = c.fetchall()
    ids = []
    data = []
    for row in all_rows:
        ids.append(str(row[0]))
        data.append(row[1:])
    X = np.array(data)
    
    estimators = {'k_means_3': KMeans(n_clusters=3),'k_means_5':KMeans(n_clusters=3),'k_means_8': KMeans(n_clusters=8)}

    est = KMeans(n_clusters=3)
    est.fit(X)
    labels = est.labels_
    labels_np = np.array(labels)
    results = []
    tsne_vals,ids2 = tsneHandler.getTSNEwithIds(tablename)
    tsne_x,tsne_y = zip(*tsne_vals)
    results = zip(ids,ids2,tsne_x,tsne_y,labels_np)
    #header = ('id','id2','tsne_x','tsne_y','lables')
    #results_w_header = header + results
    #print results_w_header
    util.writetoCSV(results, tablename + "_clustered")
Example #5
0
    #get filename
    fs = imageIDs
    N = len(fs) #N = length(fs);
    
    #size of final image
    S = 10008;
    G = np.zeros((S,S,3)) # ,'uint8'
    #print G
    # size of every image thumbnail
    s = 278
    
    
    xnum = S/s
    ynum = S/s
    used = np.zeros((N, 1))
    
    qq=len(range(0,S,s))
    
    abes = np.zeros((qq*2,2))
    print len(abes)

    i=0
    for a in range(0,S,s):
        for b in range(0,S,s):
            abes[i,:] = [a,b]
            i=i+1;
    print abes


tsne_vals,ids = tsneHandler.getTSNEwithIds("colourDistribution")
plotCompTSNE(tsne_vals, ids, "colourPlot")