Display rapidminer process result in jtable

tapankhistetapankhiste Member Posts: 4 Contributor I
edited November 2018 in Help
i tried to run one process of rapiminer in eclipse and it successfully run and result is print in console.after i make one applet form and tried to display result in applet form so how to display the particular result set in applet give a solution my code shown below....



import com.rapidminer.RapidMiner;
import com.rapidminer.Process;
import com.rapidminer.example.Attribute;
import com.rapidminer.example.Example;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.IOObject;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorException;



import java.io.File;
import java.io.IOException;
import java.util.Iterator;

import org.freehep.graphicsio.swf.DefineBits;

import com.rapidminer.operator.io.ExcelExampleSource;
import com.rapidminer.repository.IOObjectEntry;
import com.rapidminer.repository.ProcessEntry;
import com.rapidminer.repository.RepositoryLocation;
import com.rapidminer.tools.XMLException;

public class replacemiss {

    public static void main(String args[]) throws Exception {
       
    // this initializes RapidMiner with your repositories available
       
    RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
 
    RapidMiner.init();
 
    // loads the process from the repository
    Process location = new Process(new File("D:\\rm\\replacemiss.rmp"));
    //Entry entry = location.locateEntry();
    //if (entry instanceof ProcessEntry) {
        //Process process = new RepositoryProcessLocation(location).load(null);
  Operator op = location.getOperator("Read Excel");
 
  op.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, "D:\\rm\\data1.xlsx");
  Operator op1=location.getOperator("Replace Missing Values");
  op1.setParameter("attribute","Read_News");
  op1.setParameter("default", "average");
  //op1.setParameter("replenishment Value","Y");
 
 
    Operator outp = location.getOperator("Write Excel");
  outp.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, "D:\\rm\\data2.xlsx");
 
  //RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
  // RapidMiner.init();
  // Process location1 = new Process(new File("D:\\rm\\replacemiss.rmp"));
  // Operator opa = location.getOperator("Read Excel");
 
  //opa.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, "D:\\rm\\data2.xlsx");
  // Operator opa1=location.getOperator("Replace Missing Values");
  // opa1.setParameter("attribute","");
  // opa1.setParameter("default", "average");
 
 
    IOContainer ioResult = location.run();
        IOObject result = ioResult.getElementAt(0);
    // use the result(s) as needed, for example if your process just returns one ExampleSet, use this:
    if (ioResult.getElementAt(0) instanceof ExampleSet) {
        ExampleSet resultSet = (ExampleSet)ioResult.getElementAt(0);
        System.out.println(result);
        int i=0;
        for (Example example : resultSet) {
            Iterator<Attribute> allAtts = example.getAttributes().allAttributes();
           

           
           
            while(allAtts.hasNext()) {
                Attribute a = allAtts.next();
              if(i<=3)
                System.out.print(a.getName()+ "  ");
             
                i++;
            }
        }
        System.out.println("\n");
    for (Example example : resultSet) {
        Iterator<Attribute> allAtts = example.getAttributes().allAttributes();
       
       
        while(allAtts.hasNext()) {
            Attribute a = allAtts.next();
           
                    if (a.isNumerical()) {
                            double value = example.getValue(a);
                            System.out.print(value+ " " );
                            //System.out.println("\n");

                    } else {
                            String value = example.getValueAsString(a);
                            System.out.print(value+ " ");
                            //System.out.println("\n");
                    }
              }
        System.out.println("\n");
 

 
  }
   
}
 
 
    }
}
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Team Lead Software Engineering Moderator, Employee, Member, University Professor Posts: 1,806   RM Engineering
    Hi,

    you have the values available which should go into each cell. I don't understand the problem? If you don't know how to use a JTable, please have a look at some Swing tutorials on the Internet.
    As stated in the FAQ, this forum is for help with RapidMiner Studio code questions, not a general Java help forum. You won't have much luck doing your first steps in Java here.

    Regards,
    Marco
Sign In or Register to comment.