* The machine learning method to generate from.
* @param data
* The data to use perform generation.
*/
public void generate(final File method, final File data) {
EncogProgramNode createNetworkFunction = null;
this.program.addComment("Code generated by Encog v"
+ Encog.getInstance().getProperties().get(Encog.ENCOG_VERSION));
this.program.addComment("Generation Date: " + new Date().toString());
this.program.addComment("Generated code may be used freely");
this.program.addComment("http://www.heatonresearch.com/encog");
final EncogProgramNode mainClass = this.program
.createClass("EncogExample");
if (this.targetLanguage == TargetLanguage.MQL4
|| this.targetLanguage == TargetLanguage.NinjaScript) {
throw new AnalystCodeGenerationError(
"MQL4 and Ninjascript can only be generated from Encog Analyst");
}
if (data != null) {
mainClass.embedTraining(data);
if (!(this.generator instanceof GenerateEncogJavaScript)) {
mainClass.generateLoadTraining(data);
}
}
if (method != null) {
createNetworkFunction = generateForMethod(mainClass, method);
}
final EncogProgramNode mainFunction = mainClass.createMainFunction();
if (createNetworkFunction != null) {
mainFunction.createFunctionCall(createNetworkFunction, "MLMethod",
"method");
}
if (data != null) {
if (!(this.generator instanceof GenerateEncogJavaScript)) {
mainFunction.createFunctionCall("createTraining", "MLDataSet",
"training");
}
}
mainFunction
.addComment("Network and/or data is now loaded, you can add code to train, evaluate, etc.");
((ProgramGenerator) this.generator).generate(this.program,
this.embedData);
}