The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"Iterate ExampleSet and extract WordList (Java API)"

totihuetotihue Member Posts: 2 Contributor I
edited June 2019 in Help
Hi,

Use the java platform and took a while trying to go a IOContainer as FAQs should I do it this way:

FAQ >> http://rapid-i.com/rapidforum/index.php/topic,5807.0.html

IOContainer ioResult = myProcess.run(ioInput);
if (ioResult.getElementAt(0) instanceof ExampleSet) {
    ExampleSet resultSet = (ExampleSet)ioResult.getElementAt(0);
}
But it does not work, I think it may be the version of RapidMiner, I using version 5.3.013, but I've also tested with version 5.2.008 and 5.1.017. Which version of RapidMiner is the previous block of code? (Currently I using version 5.2.008)

On the other hand, if I extract the code into a IOObject [3], in the first position meeting the performance vector, in the second meeting a model (MultiModelByRegression) and in the third I find a WordList, the description of that object says com.rapidminer.operator.text.WordList but I can not create that kind of object, on which version of RapidMiner find the WordList object? (This is the code):

            IOContainer ioContainer = process.run();
            IOObject[] ioObject = new IOObject[3];
            ioObject[0] = ioContainer.getElementAt(0); //the created model
            ioObject[1] = ioContainer.getElementAt(1); //the performance vector created by a self test
            ioObject[2] = ioContainer.getElementAt(2); //the WordList
           
            MultiModelByRegression multiModel = (MultiModelByRegression) ioObject[0];
            PerformanceVector performance = (PerformanceVector) ioObject[1];
            Object exampleSetWordList =  ioObject[2]; //Here I extract the object information
Please Help me!
Thanks!!

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    the code is from 5.3.x, however it should work with slightly older and any newer versions as well. Can't say what might be wrong without an actual error message though.
    WordList is a class from the Text Processing extension.See here for sources.

    Regards,
    Marco
  • totihuetotihue Member Posts: 2 Contributor I
    This is the error:

    This

    java.lang.ClassCastException: com.rapidminer.operator.learner.meta.MultiModelByRegression cannot be cast to com.rapidminer.example.ExampleSet

    The problem is the "if" block:

    if (ioResult.getElementAt(0) instanceof ExampleSet) {
        ExampleSet resultSet = (ExampleSet)ioResult.getElementAt(0);
    }
    This instanceof is not running ok, this happens because there (on port "0") is not an exampleset, port 0 is a MultiModelByRegression, only on port 2 exists something similar to exampleset, there is a wordList, then it can not interpret the object. I've tried changing ioResult.getElementAt(0) by ioResult.getElementAt(2), but also not, I need to rescue the word, its frequency in the text and the predicted label.

    Could you tell me the conditions for the method you mention in the FAQs section, run ok? (Java version, RapidMiner version, some other library)

    I really need help with this!!

    Thank you!!!
  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    let's clarify a couple of things:

    1) The result of a RapidMiner Studio process is an IOContainer. This container can contain any number of results (including none at all). This depends on the number of connections to the process output ports. Essentially, you get the same number of results in the IOContainer as the number of connected process result ports (the ones on the top right corner of a process in RapidMiner Studio GUI). Caveat: If one or more of the lines results in a null result, it is omitted from the result IOContainer by default. Iterate over all results of a process like so:

    IOContainer container = process.run();
    for (int i = 0; i < container.size(); i++) {
    IOObject ioObject = container.getElementAt(i);
    // do something
    }
    2) All results contained in an IOContainer implement the interface "IOObject". You can detect what they really are by simply checking for expected results or calling ioObject.getClass() to find out. The most common result would be an ExampleSet (wich is the main data class of RapidMiner Studio). However you can also get a Model or a FileObject or many, many others (see the implementations of the IOObject interface by selecting it in Eclipse and pressing Ctrl+T).

    3) Extensions can define their own IOObject implementations. This is what you are faced with, because the Text Extension adds things like com.rapidminer.operator.text.Document or com.rapidminer.operator.text.WorldList to the mix. To use them programatically, you need to have the text extension sources available in your IDE. See my previous reply for a link. Once you have these sources available, you can work with the results and use them like you would for RapidMiner core IOObjects.

    Regards,
    Marco
Sign In or Register to comment.