我有一个RapidMiner文本分类的过程。 它读取指定的Excel ssheet测试数据,并做了分类。 我也有它只是运行这个过程中一个小的Java应用程序。 现在我想使文件输入部分在我aplication,所以每次我将能够从我的应用程序(而不是从RapidMiner)指定Excel文件。 任何提示?
这是代码:
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.Operator;
import com.rapidminer.operator.OperatorException;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import com.rapidminer.operator.io.ExcelExampleSource;
import com.rapidminer.tools.XMLException;
public class Classification {
public static void main(String [] args) throws Exception{
ExampleSet resultSet1 = null;
IOContainer ioInput = null;
IOContainer ioResult;
try {
RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
RapidMiner.init();
Process pr = new Process(new File("C:\\Users\\MP-TEST\\Desktop\\Rapid_Test\\Wieder_Model.rmp"));
Operator op = pr.getOperator("Read Excel");
op.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, "C:\\Users\\MP-TEST\\Desktop\\Rapid_Test\\HaendlerRatings_neu.xls");
ioResult = pr.run(ioInput);
if (ioResult.getElementAt(0) instanceof ExampleSet) {
resultSet1 = (ExampleSet)ioResult.getElementAt(0);
for (Example example : resultSet1) {
Iterator allAtts = example.getAttributes().allAttributes();
while(allAtts.hasNext()) {
Attribute a = allAtts.next();
if (a.isNumerical()) {
double value = example.getValue(a);
System.out.println(value);
} else {
String value = example.getValueAsString(a);
System.out.println(value);
}
}
}
}
} catch (IOException | XMLException | OperatorException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这是错误:
Apr 09, 2013 9:06:05 AM com.rapidminer.Process run
INFO: Process C:\Users\MP-TEST\Desktop\Rapid_Test\Wieder_Model.rmp starts
com.rapidminer.operator.UserError: A value for the parameter 'excel_file' must be specified!
at com.rapidminer.operator.nio.model.ExcelResultSetConfiguration.makeDataResultSet(ExcelResultSetConfiguration.java:316)
at com.rapidminer.operator.nio.model.AbstractDataResultSetReader.createExampleSet(AbstractDataResultSetReader.java:127)
at com.rapidminer.operator.io.AbstractExampleSource.read(AbstractExampleSource.java:52)
at com.rapidminer.operator.io.AbstractExampleSource.read(AbstractExampleSource.java:1)
at com.rapidminer.operator.io.AbstractReader.doWork(AbstractReader.java:126)
at com.rapidminer.operator.Operator.execute(Operator.java:855)
at com.rapidminer.operator.execution.SimpleUnitExecutor.execute(SimpleUnitExecutor.java:51)
at com.rapidminer.operator.ExecutionUnit.execute(ExecutionUnit.java:711)
at com.rapidminer.operator.OperatorChain.doWork(OperatorChain.java:379)
at com.rapidminer.operator.Operator.execute(Operator.java:855)
at com.rapidminer.Process.run(Process.java:949)
at com.rapidminer.Process.run(Process.java:873)
at com.rapidminer.Process.run(Process.java:832)
at com.rapidminer.Process.run(Process.java:827)
at Classification.main(Classification.java:29)
最好的祝福
武器