Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

rapidminer and java

$
0
0
Hi,
I want to create a new model of clustering, I want to start applying an algorithm (kmeans algorithm) from RapidMiner then retrieve the results (clusters and their contents) in my java program and apply other programming technique. I have the following code:

import com.rapidminer.RapidMiner;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.operator.ExecutionMode;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.IOObject;
import com.rapidminer.repository.IOObjectEntry;
import com.rapidminer.repository.ProcessEntry;
import com.rapidminer.repository.RepositoryLocation;
import java.lang.String;





public class Model {

	 public static void main(String args[]) throws Exception {
		 
	// this initializes RapidMiner with your repositories available
	 
	RapidMiner.setExecutionMode(ExecutionMode.COMMAND_
LINE);
	 
	RapidMiner.init();
	// loads the process from the repository
	RepositoryLocation pLoc = new RepositoryLocation("//C:/Users/faith/Desktop/MyRep
ository/MyData/kmeansProcess");
	ProcessEntry pEntry = (ProcessEntry) pLoc.locateEntry();
	String processXML = pEntry.retrieveXML();
	Process myProcess = new Process(processXML);
	// if need be, you can give the process IOObjects as parameter (this would be the case if you used the process input ports)
	RepositoryLocation loc = new RepositoryLocation("//C:/Users/faith/Desktop/MyRep
ository/MyData/cars");
	IOObjectEntry entry = (IOObjectEntry) loc.locateEntry();
	IOObject myIOObject= entry.retrieveData(null);

	// execute the process and get the resulting objects
	IOContainer ioInput = new IOContainer(new IOObject[] {myIOObject});
	// just use myProcess.run() if you don't use the input ports for your process
	IOContainer ioResult = myProcess.run(ioInput);

	// 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);
	}	
   }
}


But I have encountered three errors :
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
COMMAND_LINE cannot be resolved or is not a field
Cannot instantiate the type Process
The method run(IOContainer) is undefined for the type Process
at Model.main(Model.java:82)

I don't know how to solve these problems. Help me please, I really need help.
Thank you in advance

Viewing all articles
Browse latest Browse all 2703

Trending Articles