Esempio n. 1
0
def main(argv = sys.argv):
    opts, args = getopt.getopt(argv[1:], "h", ["help"])

    cfg = DefaultConfig() if (len(args)==0) else LoadConfig(args[0])

    coords_file = cfg.output.coords_file
    density_plot_file = cfg.output.density_plot_file
    if cfg.input.render_data_has_labels: 
        labels_file = cfg.output.labels_file
    else:
        labels_file = None

    render = Render(coords_file, labels_file)
    render.plot_density(density_plot_file)
Esempio n. 2
0
    #coords = scale_to_interval(coords, max=100)
    
    print 'writing coordinates to csv'
    csv_writer = csv.writer(open(output_file, 'wb'), delimiter=',')
    for r in xrange(len(coords)):
        csv_writer.writerow(coords[r].astype('|S12')) # format with 10dp accuracy (but no '-e' format stuff)

if __name__ == '__main__':

    codes_file = 'test/test_codes.csv'
    coords_file = 'out/test_coords.csv'
    
    codes = numpy.genfromtxt(codes_file, dtype=numpy.float32, delimiter=',')
    codes = codes[:,1:]
    
    for perplexity in xrange(20):
        try:
            tsne = TSNE(perplexity=perplexity, desired_dims=2)
            tsne.initialize_with_codes(codes)
            tsne.fit(iterations=500)
            tsne.save_coords_to_file(coords_file)
            
            density_plot_file = 'out/test_map_%i.png'%perplexity
            labels_file = 'test/test_labels.csv'
        
            render = Render(coords_file, labels_file)
            render.plot_density(density_plot_file)
        except:
            print 'failed to compute with perplexity %i'%perplexity
            
Esempio n. 3
0
import os, sys, getopt
from hashmapd.load_config import LoadConfig, DefaultConfig
from hashmapd.render import Render

if __name__ == '__main__':
    from optparse import OptionParser
    parser = OptionParser()
    parser.add_option("-f", "--file", dest="config", default="config",
        help="Path of the config file to use")
    (options, args) = parser.parse_args()
    cfg = LoadConfig(options.config)
    
    coords_file = cfg.output.coords_file
    density_plot_file = cfg.output.density_plot_file
    labels_file = cfg.output.labels_file

    render = Render(coords_file, labels_file)
    render.max_labels = 1000
    render.plot_density(density_plot_file)