Options

How to get the attributes from a DistributionModel.

FireholderFireholder Member Posts: 26 Contributor II
edited November 2018 in Help
I have an output which is IOObject and which is is DistributionModel at the same time. So now I want to get the attributes and values from that model. The project I'm working in is much wider and actually I want to get the output and retrieve the data from that output no matter whether it's distribution model,exampleset,etc. I'm already familiar with Examplesets and now going to work with distribution models.Any ideas?This is my code:
RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);
RapidMiner.init();
Test obj=new Test() ;
//obj.go();

// MUST BE INVOKED BEFORE ANYTHING ELSE !!!


  Process process=new Process(readFileAsString(x));
  //process.getRootOperator().getOperator(1).setParameter(key, value);
  IOContainer ioResult = process.run();
 
  DistributionModel resultSet=null;
  if (ioResult.getElementAt(0)  instanceof DistributionModel) {    
  System.out.println ("***************************");
  resultSet = (DistributionModel)ioResult.getElementAt(0);
                          }
Thanks in advance.

best regards, Fire
Tagged:

Answers

  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    I'm not sure what you want, however in RapidMiner a model is NOT a data storage like an ExampleSet.
    In your case, the only things you can get of of the DistributionModel is the distribution via model.getDistributin(classIndex, attributeIndex); and the class indicies and attribute names (see the respective getters).

    Regards,
    Marco
  • Options
    FireholderFireholder Member Posts: 26 Contributor II
    Thank you for you reply Marco. Actually I figured out how to solve the issue.And if someone will be interested, here is the code:
    DistributionModel DresultSet=null;
      ExampleSet EresultSet=null;
      //ioResult.asList();
      if (ioResult.getElementAt(0)  instanceof DistributionModel) {    
      System.out.println ("***************************");
      DresultSet = (DistributionModel) ioResult.getElementAt(0);
      DistributionModelTableRenderer a=new DistributionModelTableRenderer();
      TableModel table=a.getTableModel(DresultSet, ioResult, false);
      System.out.println(table.getColumnCount()+"distribution model");
      this.table=table;
     
      //System.out.println(resultSet.getAttributeNames().toString());
          /*RepositoryLocation resloc = new RepositoryLocation(
          "//NewLocalRepository/Project/Result");
          RepositoryManager.getInstance(null).store(resultSet, resloc, null);*/
      } else {
      if (ioResult.getElementAt(0) instanceof ExampleSet) {    
      System.out.println ("***************************");
      EresultSet = (ExampleSet) ioResult.getElementAt(0);
      TableModel table=new DataViewerTableModel(EresultSet);
      System.out.println(table.getColumnCount()+"exampleset");
      this.table=table;
      }
     
      }
    It's easier to work with a table and retrieve the data using the get methods,imho.

    rgrds,Fire
Sign In or Register to comment.