Dynamically add input from database to RapidMiner through Java

arulganesanarasarulganesanaras Member Posts: 3 Contributor I
edited November 2018 in Help
HI,

private static IOObject myExampleSet;

public static void main(String[] args) throws Exception {
JFrame frame = new JFrame("Rapidminer");
frame.setLocation(0, 0);
JLabel label = new JLabel();
frame.add(new JScrollPane(label));



final String processPath = "/C:/Users/Administrator/.RapidMiner/repositories/Local Repository/processes/clustermodel.rmp";


try {

// Init RapidMiner
RapidMiner.setExecutionMode(ExecutionMode.EMBEDDED_WITH_UI);
Plugin.setInitPlugins(true);
RapidMiner.init();

// Load process
final com.rapidminer.Process process = new com.rapidminer.Process(new File(processPath));

IOContainer ioResult = process.run();
IOObject result = ioResult.getElementAt(0); // or whatever index you
// need
String name = RendererService.getName(result.getClass());
List renderers = RendererService.getRenderers(name);

for (Renderer renderer : renderers) { // you don't really need to
// iterate over this, it's
// probably only one anyway
// ;)
IOContainer dummy = new IOContainer();
// edit size of image here
int imgWidth = 1100;
int imgHeight = 1100;
Reportable reportable = renderer.createReportable(result, ioResult, imgWidth, imgHeight);
if (reportable instanceof Renderable) {
Renderable renderable = (Renderable) reportable;
renderable.prepareRendering();
int preferredWidth = renderable.getRenderWidth(1000);
int preferredHeight = renderable.getRenderHeight(1000);
final BufferedImage img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = (Graphics2D) img.getGraphics();
graphics.setColor(Color.WHITE);
graphics.fillRect(0, 0, imgWidth, imgHeight);
// scale to whatever you need
graphics.scale(2, 2);
renderable.render(graphics, preferredWidth, preferredHeight);
label.setIcon(new ImageIcon(img));

}
}

frame.setVisible(true);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

System.out.println(ioResult);

} catch (Exception ex) {

}


This is what i have now its working fine and i want to add input from mysql or any database to rapidminer through java .
Anyone have idea about that please help me to find solution

Thank you,

Answers

  • Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn

    I'm not sure I understand what you are asking. Would you please format your code using the </> option in the format bar?

  • arulganesanarasarulganesanaras Member Posts: 3 Contributor I

    Hi, Thank you for valuable reply Here is my code

     

    try {
    RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.EMBEDDED_WITH_UI);
    RapidMiner.init();
    final String processPath = "/C:/Users/Administrator/.RapidMiner/repositories/Local Repository/processes/writexl.rmp";
    Process pr = new Process("processPath");
    Operator op = pr.getOperator("Process");
    op.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, processPath2Save);
    ioResult = pr.run(ioInput);


    } catch (Exception e) {

    }

    The above code is working fine.I want to add input from mysql or any other database instead of selecting *.rmp file.

    please help me to find solution.

Sign In or Register to comment.