def experiment_five(data_path,
                    output_path,
                    dataset_name='MNIST',
                    n_neighbors=80):
    X_lows, total_times = [], []
    for i in range(5):
        input_path = data_path_finder(data_path, dataset_name)
        LargeVis.loadfile(input_path)
        start_time = time()
        X_low = LargeVis.run(2, 16, -1, -1, -1, -1, -1, 3 * n_neighbors, -1,
                             n_neighbors)  # -1 means default value
        total_time = time() - start_time
        method = 'LargeVis'
        X_lows.append(X_low)
        total_times.append(total_time)
    X_lows = np.array(X_lows)
    total_times = np.array(total_times)
    avg_time = np.mean(total_times)
    np.save(output_path + '/{dataset_name}_{method}_{n_neighbors}'.format(dataset_name\
            =dataset_name,method=method,n_neighbors=n_neighbors), X_lows)
    print(
        'Total time for method {method} on {dataset_name} with {n_neighbors} is {avg_time}'
        .format(method=method,
                dataset_name=dataset_name,
                avg_time=avg_time,
                n_neighbors=n_neighbors))
    print('Detailed time is {total_times}'.format(total_times=total_times))
def main():
    dataset_name = 'mammoth'
    method = 'LargeVis'
    n_neighbors = 125
    input_path = data_path_finder(dataset_name)
    LargeVis.loadfile(input_path)
    start_time = time()
    X_low = LargeVis.run(2, 16, -1, -1, -1, -1, -1, 3 * n_neighbors, -1,
                         n_neighbors)  # -1 means default value
    total_time = time() - start_time
    method = 'LargeVis'
    np.save('/home/home1/hh219/PaCMAP/output_{dataset_name}_{method}_{n_neighbors}'.format(dataset_name\
        =dataset_name,method=method,n_neighbors=n_neighbors), X_low)
    print('Total time for method {method} on {dataset_name} is {total_time}'.
          format(method=method,
                 dataset_name=dataset_name,
                 total_time=total_time))
Example #3
0
def largevisproc(i_file, o_file, sim):
    import LargeVis

    outdim = 2
    threads = 24
    samples = -1
    prop = -1
    alpha = -1
    trees = -1
    neg = -1
    neigh = -1
    gamma = -1
    perp = -1

    if sim: LargeVis.loadgraph(i_file)
    else: LargeVis.loadfile(i_file)

    Y = LargeVis.run(outdim, threads, samples, prop, alpha, trees, neg, neigh,
                     gamma, perp)

    LargeVis.save(o_file)
Example #4
0
import LargeVis
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('-fea', default = 1, type = int, help = 'whether to visualize high-dimensional feature vectors or networks')
parser.add_argument('-input', default = '', help = 'input file')
parser.add_argument('-output', default = '', help = 'output file')
parser.add_argument('-outdim', default = -1, type = int, help = 'output dimensionality')
parser.add_argument('-threads', default = -1, type = int, help = 'number of training threads')
parser.add_argument('-samples', default = -1, type = int, help = 'number of training mini-batches')
parser.add_argument('-prop', default = -1, type = int, help = 'number of propagations')
parser.add_argument('-alpha', default = -1, type = float, help = 'learning rate')
parser.add_argument('-trees', default = -1, type = int, help = 'number of rp-trees')
parser.add_argument('-neg', default = -1, type = int, help = 'number of negative samples')
parser.add_argument('-neigh', default = -1, type = int, help = 'number of neighbors in the NN-graph')
parser.add_argument('-gamma', default = -1, type = float, help = 'weight assigned to negative edges')
parser.add_argument('-perp', default = -1, type = float, help = 'perplexity for the NN-grapn')

args = parser.parse_args()

if args.fea == 1:
    LargeVis.loadfile(args.input)
else:
    LargeVis.loadgraph(args.input)

Y = LargeVis.run(args.outdim, args.threads, args.samples, args.prop, args.alpha, args.trees, args.neg, args.neigh, args.gamma, args.perp)

LargeVis.save(args.output)
Example #5
0
#!/usr/bin/env python

import LargeVis
import argparse

parser = argparse.ArgumentParser()
parser.add_argument('--fea', default=1, type=int, help='whether to visualize high-dimensional feature vectors or networks')
parser.add_argument('--input', default='', help='input file', required=True)
parser.add_argument('--output', default='', help='output file', required=True)
parser.add_argument('--outdim', default=-1, type=int, help='output dimensionality')
parser.add_argument('--threads', default=-1, type=int, help='number of training threads')
parser.add_argument('--samples', default=-1, type=int, help='number of training mini-batches')
parser.add_argument('--prop', default=-1, type=int, help='number of propagations')
parser.add_argument('--alpha', default=-1, type=float, help='learning rate')
parser.add_argument('--trees', default=-1, type=int, help='number of rp-trees')
parser.add_argument('--neg', default=-1, type=int, help='number of negative samples')
parser.add_argument('--neigh', default=-1, type=int, help='number of neighbors in the NN-graph')
parser.add_argument('--gamma', default=-1, type=float, help='weight assigned to negative edges')
parser.add_argument('--perp', default=-1, type=float, help='perplexity for the NN-grapn')

args = parser.parse_args()

if args.fea == 1:
    LargeVis.loadfile(args.input)
else:
    LargeVis.loadgraph(args.input)

Y = LargeVis.run(args.outdim, args.threads, args.samples, args.prop, args.alpha, args.trees, args.neg, args.neigh, args.gamma, args.perp)

LargeVis.save(args.output)
Example #6
0
        random_indices = np.concatenate(random_indices)
        idx_filename = '.indices_year_{}.npy'.format(args.sample_size)
        np.save(args.input+idx_filename,random_indices)
        features = features[random_indices]

    # now we write the data to file in the required LargeVis format (which requires a header 
    # with the number of items and the dimensionality of the feature vectors)
    with open(args.temp+'lv_format.txt','w') as out:
        out.write("{}\t{}\n".format(*features.shape))
        for row in tq(features):
            out.write('\t'.join(row.astype(str))+'\n')
    del features

    # now run Large Vis! (in 2D mode)

    LargeVis.loadfile(args.temp+"lv_format.txt")

    # samples only matters for graph layout
    samples = -1
    gamma = -1
    Y = LargeVis.run(2, args.threads, samples, args.prop, args.alpha, args.trees, args.neg, args.neigh, gamma, args.perp)
    if args.sampling == 'by_year':
        filename = '.{}.year_lv_coords'.format(args.sample_size)
    else:
        filename = '.{}.lv_coords'.format(args.sample_size)
    LargeVis.save(args.input+filename)

    donestring = """
    -----PROCESSING COMPLETE-----
    2D Embedding saved as: {}
    """.format(args.input+filename)