我有一个需要集群的演示数据。该实用程序应该将数据发送到快速矿工算法,然后检索结果。我使用Rapid Miner API来使用快速挖掘器的现有算法。但是我遇到了使用此API的问题。
Java类:
package rajeev.rapidminer.main;
import java.io.File;
import java.io.IOException;
import com.rapidminer.Process;
import com.rapidminer.RapidMiner;
import com.rapidminer.RapidMiner.ExecutionMode;
import com.rapidminer.operator.IOObject;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.repository.IOObjectEntry;
import com.rapidminer.repository.MalformedRepositoryLocationException;
import com.rapidminer.repository.RepositoryException;
import com.rapidminer.repository.RepositoryLocation;
import com.rapidminer.tools.XMLException;
public class Main {
public static void main(String a[]) throws IOException, XMLException, RepositoryException, OperatorException
{
String rmpPath="C:/Users/rajeev-s/.RapidMiner5/repositories/Local Repository/DemoClustering.rmp";
RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);
RapidMiner.init();
Process process=new Process(new File(rmpPath));
RepositoryLocation modelLocation=new RepositoryLocation("//C:/Users/rajeev-s/.RapidMiner5/repositories/Local Repository/ClusterDemoOutput");
IOObject model=((IOObjectEntry)modelLocation.locateEntry()).retrieveData(null);
RepositoryLocation testDataLocation=new RepositoryLocation("//LocalRepository/TestData.txt");
IOObject testData=((IOObjectEntry)testDataLocation.locateEntry()).retrieveData(null);
com.rapidminer.operator.IOContainer ioInput = new com.rapidminer.operator.IOContainer(new IOObject[] { model, testData });
process.run(ioInput);
process.run(ioInput);
final long start = System.currentTimeMillis();
final com.rapidminer.operator.IOContainer ioResult = process.run(ioInput);
final long end = System.currentTimeMillis();
System.out.println("T:" + (end - start));
}
}
错误堆栈跟踪是:
Oct 25, 2013 6:28:53 PM com.rapidminer.tools.ParameterService init
INFO: Reading configuration resource com/rapidminer/resources/rapidminerrc.
Oct 25, 2013 6:28:53 PM com.rapidminer.tools.I18N <clinit>
INFO: Set locale to en.
Oct 25, 2013 6:28:54 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Property rapidminer.home is not set. Guessing.
Oct 25, 2013 6:28:54 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Trying parent directory of 'C:\Program Files\Rapid- I\RapidMiner5\lib\launcher.jar'...gotcha!
Oct 25, 2013 6:28:54 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Trying parent directory of 'C:\Program Files\Rapid- I\RapidMiner5\lib\rapidminer.jar'...gotcha!
Oct 25, 2013 6:29:00 PM com.rapidminer.tools.expression.parser.ExpressionParserFactory <clinit>
INFO: Default version of expression parser registered successfully
Oct 25, 2013 6:29:06 PM com.rapidminer.parameter.ParameterTypePassword decryptPassword
WARNING: Password in XML file looks like unencrypted plain text.
Oct 25, 2013 6:29:10 PM com.rapidminer.tools.OperatorService init
INFO: Number of registered operator classes: 443; number of registered operator descriptions: 444; number of replacements: 403
Oct 25, 2013 6:29:10 PM com.rapidminer.tools.jdbc.JDBCProperties <init>
警告:缺少ODBC Bridge的数据库驱动程序类名(例如Access) 2013年10月25日下午6:29:10 com.rapidminer.tools.jdbc.JDBCProperties registerDrivers 信息:找不到JDBC驱动程序ca.ingres.jdbc.IngresDriver。可能没有安装驱动程序。 [致命错误]:1:1:文件过早结束。 线程“main”中的异常com.rapidminer.repository.RepositoryException:请求的存储库C:不存在。 at com.rapidminer.repository.RepositoryManager.getRepository(RepositoryManager.java:201) at com.rapidminer.repository.RepositoryLocation.getRepository(RepositoryLocation.java:139) at com.rapidminer.repository.RepositoryLocation.locateEntry(RepositoryLocation.java:162) 在rajeev.rapidminer.main.Main.main(Main.java:29)
当我将“本地存储库”复制到我的类路径并将路径更改为:
时//Local Repository/ClusterDemoOutput
然后生成跟踪堆栈跟踪:
Exception in thread "main" com.rapidminer.repository.RepositoryException: Requested repository LocalRepository does not exist.
at com.rapidminer.repository.RepositoryManager.getRepository(RepositoryManager.java:201)
at com.rapidminer.repository.RepositoryLocation.getRepository(RepositoryLocation.java:139)
at com.rapidminer.repository.RepositoryLocation.locateEntry(RepositoryLocation.java:162)
at rajeev.rapidminer.main.Main.main(Main.java:29)
请告诉我在哪里放置存储库。
另外请建议任何适当的博客或教程,解释如何使用java代码中的Rapid Miner算法(我在谷歌上搜索的内容并未提及所有细节)
由于
答案 0 :(得分:1)
我为上述问题找到了一个有效的解决方案。我不确定它是否是最好的,但它对我有用。
public class MinerForum {
public static void main(String a[]) throws IOException, XMLException, RepositoryException, OperatorException
{
int[] data={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
List<Attribute> attributes=new ArrayList<Attribute>();
String[] columns={"column1"};
DataTable table=new SimpleDataTable("table1",columns);
for(int i=0;i<21;i++)
{
double[] value={i};
DataTableRow row=new SimpleDataTableRow(value, i+"");
table.add(row);
}
RapidMiner.setExecutionMode(ExecutionMode.COMMAND_LINE);
RapidMiner.init();
com.rapidminer.Process myProcess = new com.rapidminer.Process(new File ("D:\\drools\\Repository1\\Example1.rmp"));
IOContainer ioInput = new IOContainer();
IOContainer ioResult = myProcess.run(ioInput);
// simple use 'ioResult' to display the results you want.
}
}
答案 1 :(得分:0)
确定
new RepositoryLocation("//C:/Users/
是有效位置?对我而言,它看起来更像是一个错字。
但是,您应该在rapidminer论坛中提问;你更有可能在那里与快速通道专家交谈,而不是在通用编程网站上。