Integration of Rapidminer with Java: Obtaining the output Example Set (Process Result) -
i want execute rapidminer process java use output exampleset (process result) subsequent operations (with java).
i managed process execution code below, don't have clue how obtain process result example set.
ideally, want example set independent of variables, if need generate metadata beforehand, have be.
package com.companyname.rm; import com.rapidminer.process; import com.rapidminer.rapidminer; import com.rapidminer.operator.operatorexception; import com.rapidminer.tools.xmlexception; import java.io.file; import java.io.ioexception; public class runprocess { public static void main(string[] args) { try { rapidminer.setexecutionmode(rapidminer.executionmode.command_line); rapidminer.init(); process process = new process(new file("//my_path/..../test_java.rmp")); process.run(); } catch (ioexception | xmlexception | operatorexception ex) { ex.printstacktrace(); } } }
to obtain exampleset of process need add
iocontainer ioresult = process.run();
a shortened example taken http://allinoneat.blogspot.de/2013/04/integrate-rapidminer-wtih-java.html
iocontainer ioresult = process.run(); if (ioresult.getelementat(0) instanceof exampleset) { exampleset resultset = (exampleset) ioresult.getelementat(0); (example example : resultset) { iterator<attribute> allatts = example.getattributes().allattributes(); while (allatts.hasnext()) { attribute = allatts.next(); if (a.isnumerical()) { double value = example.getvalue(a); system.out.print(value + " "); } else { string value = example.getvalueasstring(a); system.out.print(value + " "); } } system.out.println("\n"); } }
Comments
Post a Comment