def main(): parser = argparse.ArgumentParser( description='Writes a binary version of an Andrews format corpus.') parser.add_argument('--input', '-i', metavar='FILE', help='The input corpus (in Andrews format).') args = parser.parse_args() aesir.dataread(args.input)
def main(): parser = argparse.ArgumentParser( description='Runs the Andrews model.') parser.add_argument('--input', '-i', metavar='FILE', help='Load a precreated Numpy Array as the data matrix.') parser.add_argument('--output', '-o', metavar='FILE', help='Save the model.') parser.add_argument('--topics', '-k', metavar='INT', default=100, type=int, help='The number of topics to load.') parser.add_argument('--burnin', '-b', metavar='INT', type=int, default=0, help='Burnin samples.') parser.add_argument('--iterations', '-I', metavar='INT', default=1000, type=int, help='Number of iterations.') parser.add_argument('--threads', '-t', metavar='INT', default=4, type=int, help='The number of separate threads to run.') parser.add_argument('--continue', '-c', action='store_true', dest='kontinue', help='Continue computing from an existing model.') args = parser.parse_args() logging.info("Loading data...") data = aesir.dataread(args.input) logging.info("Initializing model...") model = aesir.freyr(data, K=args.topics, model_out=args.output) logging.info("Finished initializing.") if args.kontinue: logging.info("Loading existing model...") try: model.load_model(args.output) logging.info("Existing model loaded.") except IOError: logging.info("Can't continue. Starting from scratch.") logging.info("Starting MCMC...") model.burnin_iterations = args.burnin model.mcmc_iterations_max = args.iterations model.mcmc(cores=args.threads) logging.info("Finished with MCMC!") logging.info("Saving model to '%s'..." % args.output) model.save_model(args.output) logging.info("Model saved.") logging.info("All finished.")
def main(): parser = argparse.ArgumentParser(description='Runs the Andrews model.') parser.add_argument( '--input', '-i', metavar='FILE', help='Load a precreated Numpy Array as the data matrix.') parser.add_argument('--output', '-o', metavar='FILE', help='Save the model.') parser.add_argument('--topics', '-k', metavar='INT', default=100, type=int, help='The number of topics to load.') parser.add_argument('--burnin', '-b', metavar='INT', type=int, default=0, help='Burnin samples.') parser.add_argument('--iterations', '-I', metavar='INT', default=1000, type=int, help='Number of iterations.') parser.add_argument('--threads', '-t', metavar='INT', default=4, type=int, help='The number of separate threads to run.') parser.add_argument('--continue', '-c', action='store_true', dest='kontinue', help='Continue computing from an existing model.') args = parser.parse_args() logging.info("Loading data...") data = aesir.dataread(args.input) logging.info("Initializing model...") model = aesir.freyr(data, K=args.topics, model_out=args.output) logging.info("Finished initializing.") if args.kontinue: logging.info("Loading existing model...") try: model.load_model(args.output) logging.info("Existing model loaded.") except IOError: logging.info("Can't continue. Starting from scratch.") logging.info("Starting MCMC...") model.burnin_iterations = args.burnin model.mcmc_iterations_max = args.iterations model.mcmc(cores=args.threads) logging.info("Finished with MCMC!") logging.info("Saving model to '%s'..." % args.output) model.save_model(args.output) logging.info("Model saved.") logging.info("All finished.")