private static boolean parseArgs(String[] args) { DefaultOptionBuilder builder = new DefaultOptionBuilder(); Option help = builder.withLongName("help").withDescription("print this list").create(); Option quiet = builder.withLongName("quiet").withDescription("be extra quiet").create(); Option auc = builder.withLongName("auc").withDescription("print AUC").create(); Option confusion = builder.withLongName("confusion").withDescription("print confusion matrix").create(); Option scores = builder.withLongName("scores").withDescription("print scores").create(); ArgumentBuilder argumentBuilder = new ArgumentBuilder(); Option inputFileOption = builder .withLongName("input") .withRequired(true) .withArgument(argumentBuilder.withName("input").withMaximum(1).create()) .withDescription("where to get training data") .create(); Option modelFileOption = builder .withLongName("model") .withRequired(true) .withArgument(argumentBuilder.withName("model").withMaximum(1).create()) .withDescription("where to get a model") .create(); Group normalArgs = new GroupBuilder() .withOption(help) .withOption(quiet) .withOption(auc) .withOption(scores) .withOption(confusion) .withOption(inputFileOption) .withOption(modelFileOption) .create(); Parser parser = new Parser(); parser.setHelpOption(help); parser.setHelpTrigger("--help"); parser.setGroup(normalArgs); parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130)); CommandLine cmdLine = parser.parseAndHelp(args); if (cmdLine == null) { return false; } inputFile = getStringArgument(cmdLine, inputFileOption); modelFile = getStringArgument(cmdLine, modelFileOption); showAuc = getBooleanArgument(cmdLine, auc); showScores = getBooleanArgument(cmdLine, scores); showConfusion = getBooleanArgument(cmdLine, confusion); return true; }
public static boolean parseArgs(String[] args) { DefaultOptionBuilder builder = new DefaultOptionBuilder(); Option help = builder.withLongName("help").withDescription("print this list").create(); ArgumentBuilder argumentBuilder = new ArgumentBuilder(); Option inputFile = builder .withLongName("input") .withRequired(true) .withArgument(argumentBuilder.withName("input").withMaximum(1).create()) .withDescription("where to get training data") .create(); Option outputFile = builder .withLongName("output") .withRequired(true) .withArgument(argumentBuilder.withName("output").withMaximum(1).create()) .withDescription("where to get training data") .create(); Option passes = builder .withLongName("passes") .withArgument( argumentBuilder.withName("passes").withDefault("2").withMaximum(1).create()) .withDescription("the number of times to pass over the input data") .create(); Option lambda = builder .withLongName("lambda") .withArgument( argumentBuilder.withName("lambda").withDefault("1e-4").withMaximum(1).create()) .withDescription("the amount of coefficient decay to use") .create(); Option rate = builder .withLongName("rate") .withArgument( argumentBuilder .withName("learningRate") .withDefault("1e-3") .withMaximum(1) .create()) .withDescription("the learning rate") .create(); Group normalArgs = new GroupBuilder() .withOption(help) .withOption(inputFile) .withOption(outputFile) .withOption(passes) .withOption(lambda) .withOption(rate) .create(); Parser parser = new Parser(); parser.setHelpOption(help); parser.setHelpTrigger("--help"); parser.setGroup(normalArgs); parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130)); CommandLine cmdLine = parser.parseAndHelp(args); if (cmdLine == null) { return false; } TrainLogistic.inputFile = getStringArgument(cmdLine, inputFile); TrainLogistic.outputFile = getStringArgument(cmdLine, outputFile); TrainLogistic.passes = getIntegerArgument(cmdLine, passes); lrs.optimizer() .setStepSize(getDoubleArgument(cmdLine, rate)) .setUpdater(new L1Updater()) .setRegParam(getDoubleArgument(cmdLine, lambda)) .setNumIterations(TrainLogistic.passes) .setMiniBatchFraction(1.0); lrs.setIntercept(true); return true; }
private static boolean parseArgs(String[] args) { DefaultOptionBuilder builder = new DefaultOptionBuilder(); Option help = builder.withLongName("help").withDescription("print this list").create(); Option quiet = builder.withLongName("quiet").withDescription("be extra quiet").create(); ArgumentBuilder argumentBuilder = new ArgumentBuilder(); Option inputFileOption = builder .withLongName("input") .withRequired(true) .withArgument(argumentBuilder.withName("input").withMaximum(1).create()) .withDescription("where to get training data") .create(); Option modelFileOption = builder .withLongName("model") .withRequired(true) .withArgument(argumentBuilder.withName("model").withMaximum(1).create()) .withDescription("where to get the trained model") .create(); Option outputFileOption = builder .withLongName("output") .withRequired(true) .withDescription("the file path to output scores") .withArgument(argumentBuilder.withName("output").withMaximum(1).create()) .create(); Option idColumnOption = builder .withLongName("idcolumn") .withRequired(true) .withDescription("the name of the id column for each record") .withArgument(argumentBuilder.withName("idcolumn").withMaximum(1).create()) .create(); Option maxScoreOnlyOption = builder .withLongName("maxscoreonly") .withDescription("only output the target label with max scores") .create(); Group normalArgs = new GroupBuilder() .withOption(help) .withOption(quiet) .withOption(inputFileOption) .withOption(modelFileOption) .withOption(outputFileOption) .withOption(idColumnOption) .withOption(maxScoreOnlyOption) .create(); Parser parser = new Parser(); parser.setHelpOption(help); parser.setHelpTrigger("--help"); parser.setGroup(normalArgs); parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130)); CommandLine cmdLine = parser.parseAndHelp(args); if (cmdLine == null) { return false; } inputFile = getStringArgument(cmdLine, inputFileOption); modelFile = getStringArgument(cmdLine, modelFileOption); outputFile = getStringArgument(cmdLine, outputFileOption); idColumn = getStringArgument(cmdLine, idColumnOption); maxScoreOnly = getBooleanArgument(cmdLine, maxScoreOnlyOption); return true; }