How to get the attributes from a DistributionModel.
Fireholder
New Altair Community Member
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:
best regards, Fire
RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);Thanks in advance.
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);
}
best regards, Fire
0
Answers
-
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,
Marco0 -
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;
It's easier to work with a table and retrieve the data using the get methods,imho.
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;
}
}
rgrds,Fire0