/** {@inheritDoc} */ @Override public final boolean executeCommand(final String args) { // get filenames final String evalID = getProp().getPropertyString(ScriptProperties.ML_CONFIG_EVAL_FILE); final String resourceID = getProp().getPropertyString(ScriptProperties.ML_CONFIG_MACHINE_LEARNING_FILE); final String outputID = getProp().getPropertyString(ScriptProperties.ML_CONFIG_OUTPUT_FILE); EncogLogging.log(EncogLogging.LEVEL_DEBUG, "Beginning evaluate raw"); EncogLogging.log(EncogLogging.LEVEL_DEBUG, "evaluate file:" + evalID); EncogLogging.log(EncogLogging.LEVEL_DEBUG, "resource file:" + resourceID); final File evalFile = getScript().resolveFilename(evalID); final File resourceFile = getScript().resolveFilename(resourceID); final File outputFile = getAnalyst().getScript().resolveFilename(outputID); final MLRegression method = (MLRegression) EncogDirectoryPersistence.loadObject(resourceFile); final boolean headers = getScript().expectInputHeaders(evalID); final AnalystEvaluateRawCSV eval = new AnalystEvaluateRawCSV(); eval.setScript(getScript()); getAnalyst().setCurrentQuantTask(eval); eval.setReport(new AnalystReportBridge(getAnalyst())); eval.analyze( getAnalyst(), evalFile, headers, getProp().getPropertyCSVFormat(ScriptProperties.SETUP_CONFIG_CSV_FORMAT)); eval.process(outputFile, method); getAnalyst().setCurrentQuantTask(null); return eval.shouldStop(); }
public static void train(File dataDir) { final File networkFile = new File(dataDir, Config.NETWORK_FILE); final File trainingFile = new File(dataDir, Config.TRAINING_FILE); // network file if (!networkFile.exists()) { System.out.println("Can't read file: " + networkFile.getAbsolutePath()); return; } BasicNetwork network = (BasicNetwork) EncogDirectoryPersistence.loadObject(networkFile); // training file if (!trainingFile.exists()) { System.out.println("Can't read file: " + trainingFile.getAbsolutePath()); return; } final MLDataSet trainingSet = EncogUtility.loadEGB2Memory(trainingFile); // train the neural network EncogUtility.trainConsole(network, trainingSet, Config.TRAINING_MINUTES); System.out.println("Final Error: " + (float) network.calculateError(trainingSet)); System.out.println("Training complete, saving network."); EncogDirectoryPersistence.saveObject(networkFile, network); System.out.println("Network saved."); Encog.getInstance().shutdown(); }