Options

rapidMiner with java problems

magniolia92magniolia92 Member Posts: 4 Contributor I
edited September 2019 in Help
hi , I'm doing the sentiment analysis using rapidMiner 5 , I build a process and I want to see results in eclips , I follow the documentation , and I connected eclipse with rapidMiner , I create a new class and I add the RapidMiner-unk project and I put those line of code

package rm.com;

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;
import com.rapidminer.Process;

public class rm {
    public static void main(String args[]) throws Exception {  
   // this initializes RapidMiner with your repositories available
    RapidMiner.setExecutionMode(com.rapidminer.RapidMiner.ExecutionMode.COMMAND_LINE);
   RapidMiner.init();
   // loads the process from the repository
   RepositoryLocation pLoc = new RepositoryLocation("//C:/Users/fujitsu/.RapidMiner5/repositories/Local Repository/exple1");
   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/MyRepository/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 these errores occure when I start runnig

24 mars 2013 16:48:05 com.rapidminer.tools.ParameterService init
INFO: Reading configuration resource com/rapidminer/resources/rapidminerrc.
24 mars 2013 16:48:05 com.rapidminer.tools.I18N <clinit>
INFO: Set locale to en.
24 mars 2013 16:48:05 com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Property rapidminer.home is not set. Guessing.
24 mars 2013 16:48:05 com.rapid_i.Launcher ensureRapidMinerHomeSet
INFO: Trying base directory of classes (build) 'C:\workspace\rapidMiner'...gotcha!
24 mars 2013 16:48:08 com.rapidminer.tools.plugin.Plugin registerPlugins
INFO: Register plugin: Text Processing
24 mars 2013 16:48:08 com.rapidminer.tools.plugin.Plugin registerPlugins
INFO: Register plugin: Weka
24 mars 2013 16:48:08 com.rapidminer.tools.plugin.Plugin registerPlugins
INFO: Register plugin: Web Mining
24 mars 2013 16:48:26 com.rapidminer.tools.expression.parser.ExpressionParserFactory <clinit>
INFO: Default version of Expression parser registered successfully
24 mars 2013 16:48:29 com.rapidminer.parameter.ParameterTypePassword decryptPassword
WARNING: Password in XML file looks like unencrypted plain text.
24 mars 2013 16:48:44 com.rapidminer.tools.OperatorService init
INFO: Number of registered operator classes: 518; number of registered operator descriptions: 644; number of replacements: 441
24 mars 2013 16:48:45 com.rapidminer.tools.jdbc.JDBCProperties <init>
WARNING: Missing database driver class name for ODBC Bridge (e.g. Access)
24 mars 2013 16:48:45 com.rapidminer.tools.jdbc.JDBCProperties registerDrivers
INFO: JDBC driver ca.ingres.jdbc.IngresDriver not found. Probably the driver is not installed.
[Fatal Error] :1:1: Premature end of file.
Exception in thread "main" com.rapidminer.repository.RepositoryException: Requested repository C: does not exist.
at com.rapidminer.repository.RepositoryManager.getRepository(RepositoryManager.java:200)
at com.rapidminer.repository.RepositoryLocation.getRepository(RepositoryLocation.java:139)
at com.rapidminer.repository.RepositoryLocation.locateEntry(RepositoryLocation.java:162)
at rm.com.rm.main(rm.java:21)

the results that I get from rapidMiner
image

on eclipe I just want to get the content of the metadata file and the prediction label , can anyone help me , thanks

NB : I run the new project and the rapidminer-unuk using jre7 , does that cause problem ?
Tagged:

Answers

  • Options
    Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    Hi,

    the repository location does expect locations in the RapidMiner repository not on the file system.
    If you have a repository called 'Test' a valid location would be new RepositoryLocation("//test/folder1/process/").

    Best,
    Nils
  • Options
    magniolia92magniolia92 Member Posts: 4 Contributor I
    where do I have to create the new repository Test , under local repository ?
  • Options
    Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    You have to create a new repository that points to your file on disk and then you can use the repository location.

    ...
    RepositoryManager.getInstance(null).addRepository(new LocalRepository("Test", new File("C:/Users/fujitsu/.RapidMiner5/repositories/Local Repository/")));
    RepositoryLocation pLoc = new RepositoryLocation("//Test/exple1");
    ProcessEntry pEntry = (ProcessEntry) pLoc.locateEntry();
    ...
    or if it is already there because you called RapidMiner.init() before you can skip adding a new repository:

    ...
    RepositoryLocation pLoc = new RepositoryLocation("//Local Repository/exple1");
    ProcessEntry pEntry = (ProcessEntry) pLoc.locateEntry();
    ...
    Best,
    Nils
  • Options
    magniolia92magniolia92 Member Posts: 4 Contributor I
    the first problem is solved but a new problem appears now

    mars 26, 2013 10:03:46 PM com.rapidminer.tools.ParameterService init
    INFO: Reading configuration resource com/rapidminer/resources/rapidminerrc.
    Mar 26, 2013 10:03:46 PM com.rapidminer.tools.I18N <clinit>
    INFO: Set locale to en.
    Mar 26, 2013 10:03:46 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
    INFO: Property rapidminer.home is not set. Guessing.
    Mar 26, 2013 10:03:46 PM com.rapid_i.Launcher ensureRapidMinerHomeSet
    INFO: Trying base directory of classes (build) 'C:\workspace\RapidM'...gotcha!
    Mar 26, 2013 10:03:46 PM com.rapidminer.tools.plugin.Plugin registerPlugins
    INFO: Register plugin: Text Processing
    Mar 26, 2013 10:03:46 PM com.rapidminer.tools.plugin.Plugin registerPlugins
    INFO: Register plugin: Web Mining
    Mar 26, 2013 10:03:46 PM com.rapidminer.tools.plugin.Plugin registerPlugins
    INFO: Register plugin: Reporting
    Mar 26, 2013 10:03:48 PM com.rapidminer.tools.expression.parser.ExpressionParserFactory <clinit>
    INFO: Default version of expression parser registered successfully
    Mar 26, 2013 10:03:48 PM com.rapidminer.parameter.ParameterTypePassword decryptPassword
    WARNING: Password in XML file looks like unencrypted plain text.
    Mar 26, 2013 10:03:49 PM com.rapidminer.tools.OperatorService init
    INFO: Number of registered operator classes: 515; number of registered operator descriptions: 516; number of replacements: 442
    Mar 26, 2013 10:03:49 PM com.rapidminer.tools.jdbc.JDBCProperties <init>
    WARNING: Missing database driver class name for ODBC Bridge (e.g. Access)
    Mar 26, 2013 10:03:49 PM com.rapidminer.tools.jdbc.JDBCProperties registerDrivers
    INFO: JDBC driver ca.ingres.jdbc.IngresDriver not found. Probably the driver is not installed.
    Mar 26, 2013 10:03:49 PM com.rapidminer.tools.jdbc.JDBCProperties registerDrivers
    INFO: JDBC driver oracle.jdbc.driver.OracleDriver not found. Probably the driver is not installed.
    [Fatal Error] :1:1: Premature end of file.
    Exception in thread "main" java.lang.NullPointerException
    at rapid.main(rapid.java:25)

    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 com.rapidminer.repository.RepositoryManager;
    import com.rapidminer.repository.local.LocalRepository;

    import java.io.File;
    import java.lang.String;
    import com.rapidminer.Process;

    public class rapid {
        public static void main(String args[]) throws Exception { 
       
            RapidMiner.setExecutionMode(com.rapidminer.RapidMiner.ExecutionMode.COMMAND_LINE);
        RapidMiner.init();
        RepositoryManager.getInstance(null).addRepository(new LocalRepository("Test", new File("C:/Users/fujitsu/.RapidMiner5/repositories/Local Repository/")));
        RepositoryLocation pLoc = new RepositoryLocation("//Test/essai");
        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("//Test/essai");
        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);
        }   
      }
      }
  • Options
    Marco_BoeckMarco_Boeck Administrator, Moderator, Employee, Member, University Professor Posts: 1,993 RM Engineering
    Hi,

    the entry you specified could not be found, as pLoc.locateEntry(); will return null if nothing is there.
    As an alternative if you do not have and do not want to setup a RapidMiner repository, you can use this:

    Process myProcess = new Process(new File("C:\\path\\to\\your\\file\\processName.rmp"));
    Regards,
    Marco
Sign In or Register to comment.