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

"[SOLVED] Problems with Set Role and ECODB in Java Code"

DGSunicanDGSunican Member Posts: 2 Contributor I
edited June 2019 in Help
Hello all,

I am having a problem integrating RapidMiner in my Java Code. I am using 5.3.013 version.

What i want to do is the next process:
1. Read a Weak .arff file.
2. Set as label the last nominal attribute, named "note"
3. Apply the ECODB algorithm in order to detect class-outliers
4. Save the resulting set, with the instances marked as outliers, in a new .arff file

Following the documentation in the RapidMiner Wiki, i have implement the following Java method to perform the mentioned steps:
try{
           //initialized RapidMiner
           RapidMiner.init();
           
       } catch(Exception e){System.out.println("Exception initializating Rapidminer, method RapidMiner.init(): "+e);}
       
       /*
        * Creates a new process. This process will contain the
        * whole sequence of reading the .arff Weka file, making the
        * outlier instances and finally saving the .arff Weka file with
        * the marked instances
        */
       com.rapidminer.Process outlierProcess = new com.rapidminer.Process();
       
       try{
           //Operator for reading the .arff Weka file
           Operator initialDatasetECODB =
                   OperatorService.createOperator(com.rapidminer.operator.io.ArffExampleSource.class);
           
           //Operator to perform EDOCB algorithm
           Operator ecodb =
                   OperatorService.createOperator(com.rapidminer.operator.preprocessing.outlier.EcodbOperator.class);
           
           //Operator for saving the markedDataset
           Operator markedDatasetECODB =
                   OperatorService.createOperator(com.rapidminer.operator.io.ArffExampleSetWriter.class);
           
           //Operator for labeling the initial dataset
           Operator labeling =
                   OperatorService.createOperator(
                   com.rapidminer.operator.preprocessing.filter.ChangeAttributeRole.class);
           
           
           //Configures the "read arff" operator to read the dataset file with ID assigned per instance
           initialDatasetECODB.setParameter(
                   com.rapidminer.operator.io.ArffExampleSource.PARAMETER_DATA_FILE,
                   //this.directorio.getAbsolutePath()+"\\originalDataSet.arff");
                   "C:/originalDataSet.arff");

         
           //Configures the ECODB operator
           ecodb.setParameter(
                   com.rapidminer.operator.preprocessing.outlier.EcodbOperator.PARAMETER_NUMBER_OF_NEIGHBORS,
                   ""+this.k+"");
           ecodb.setParameter(
                   com.rapidminer.operator.preprocessing.outlier.EcodbOperator.PARAMETER_NUMBER_OF_Class_OUTLIERS,
                   ""+this.numOutliers+"");
           
           //Configures the operator to save the marked dataset
           markedDatasetECODB.setParameter(com.rapidminer.operator.io.ArffExampleSetWriter.PARAMETER_EXAMPLE_SET_FILE,
                   this.directorio.getAbsolutePath()+"\\markedDataset.arff");
           
           //Configures the operator for labeling the initial dataset
           labeling.setParameter(
                   com.rapidminer.operator.preprocessing.filter.ChangeAttributeRole.PARAMETER_TARGET_ROLE,
                   Attributes.LABEL_NAME);
           labeling.setParameter(
                   com.rapidminer.operator.preprocessing.filter.ChangeAttributeRole.PARAMETER_NAME,
                   "note");
           
           //Adds the operators to the process
           outlierProcess.getRootOperator().getSubprocess(0).addOperator(initialDatasetECODB);
           outlierProcess.getRootOperator().getSubprocess(0).addOperator(ecodb);
           outlierProcess.getRootOperator().getSubprocess(0).addOperator(markedDatasetECODB);
           outlierProcess.getRootOperator().getSubprocess(0).addOperator(labeling);

           
           
           
           //Conects the reader operator to the ecodb operator
           try{
           initialDatasetECODB.getOutputPorts().getPortByName("output")
                   .connectTo(labeling.getInputPorts().getPortByName("example set input"));
           }catch(Exception e){System.out.println("Error in initialDataset operator");}
           try{
           labeling.getOutputPorts().getPortByName("example set output")
                   .connectTo(ecodb.getInputPorts().getPortByName("example set input"));
           
           }catch(Exception e){System.out.println("Error in labeling operator: "+e);}
           try{
           ecodb.getOutputPorts().getPortByName("example set output")
                   .connectTo(markedDatasetECODB.getInputPorts().getPortByName("input"));
           }catch(Exception e){System.out.println("Error in ecodb  operator");}
           
           //Run the whole process
           outlierProcess.run();
           
       }catch (Exception e){ System.out.println("Exception trying to execute the ECODB RapidMiner process "+e);}
       
When i execute it, i get the following Exception:
Exception trying to execute the ECODB RapidMiner process com.rapidminer.operator.UserError: No data was delivered at port Detect Outlier (COF).example set input (connected). 
It seems that the output port of the Set_Role class, "Example output set", do not return nothing. I have tried to connect, directly, the ECODB class to the readArff class, and they seems to connect correctly, but of course ECODB launch en exception requiering to stablish a label attribute, and it only can be done with the Set_Role operation, which do not work correctly.

I hope someone in this forum could help me with this issue.

Thank you very much.


Answers

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

    Please have a look at the sticky thread in the development forum: http://rapid-i.com/rapidforum/index.php/topic,5807.0.html

    What I always recommend is to not create your own process by hand (i.e. don't create operators yourself) but to rather use a predefined process which has been created via RM Studio GUI. That makes things A LOT less prone  to errors.

    Regards,
    Marco
  • DGSunicanDGSunican Member Posts: 2 Contributor I
    Marco Boeck wrote:

    Hi,

    Please have a look at the sticky thread in the development forum: http://rapid-i.com/rapidforum/index.php/topic,5807.0.html

    What I always recommend is to not create your own process by hand (i.e. don't create operators yourself) but to rather use a predefined process which has been created via RM Studio GUI. That makes things A LOT less prone  to errors.

    Regards,
    Marco

    Thank you so much Marco, it worked for me. Problem solved!
Sign In or Register to comment.