Testing the data set against model.

srini
srini New Altair Community Member
edited November 5 in Community Q&A
I was able to generate the model by applying the operators programmitically. But I am facing difficulty in testing the dataset against the model. The test data and the train data set are in the format of csv.

Below is the sample code, could you please tell me what I am doing wrong asap?

Operator csvReader1 = OperatorService.createOperator(CSVExampleSource.class);
        csvReader1.setParameter(CSVExampleSource.PARAMETER_CSV_FILE, "E://Rapid//RapidRepository//classification//classification_data_test_set.csv");
        csvReader1.setParameter(CSVExampleSource.PARAMETER_COLUMN_SEPARATORS, ",");
        csvReader1.setParameter(CSVExampleSource.PARAMETER_TRIM_LINES, "true");
        csvReader1.setParameter(CSVExampleSource.PARAMETER_FIRST_ROW_AS_NAMES, "true");
        csvReader1.setParameter(CSVExampleSource.PARAMETER_META_DATA, metaData);
       
        Operator ReadModelOperator = OperatorService.createOperator(ModelLoader.class);
        ReadModelOperator.setParameter("model_file", "E://Rapid//RapidRepository//classification//class.model");
       
        Operator modelApplier = OperatorService.createOperator(ModelApplier.class);
        modelApplier.setParameter("keep_model", "false");
     
        csvReader1.getOutputPorts().getPortByName("output").connectTo(modelApplier.getInputPorts().getPortByName("unlabelled data"));
        ReadModelOperator.getOutputPorts().getPortByName("output").connectTo(modelApplier.getInputPorts().getPortByName("model"));
       
        Process process1 = new Process();
        process1.getRootOperator().getSubprocess(0).addOperator(csvReader1);
        process1.getRootOperator().getSubprocess(0).addOperator(ReadModelOperator);
        process1.getRootOperator().getSubprocess(0).addOperator(modelApplier);
        ExampleSet resultSet = process1.run().get(ExampleSet.class);

Below is the exception

Exception in thread "main" com.rapidminer.operator.MissingIOObjectException: The operator needs some input of type com.rapidminer.example.ExampleSet which is not provided.
        at com.rapidminer.operator.IOContainer.getInput(IOContainer.java:185)
        at com.rapidminer.operator.IOContainer.get(IOContainer.java:129)

Answers

  • aborg
    aborg New Altair Community Member
    Does your process needs input? Because it seems you have not provided any ExampleSets for your run method.
  • srini
    srini New Altair Community Member
    The operators by itself feed data so that the model can be applied to the data.
    When I run the process, the result should be the predicted value for the feeded data
  • Marco_Boeck
    Marco_Boeck New Altair Community Member
    Hi,

    is there any particular reason why you are using the much more error-prone approach of constructing the process programatically instead of using one you created via the GUI as described here?

    Regards,
    Marco
  • aborg
    aborg New Altair Community Member
    Sorry, I have not realized the problem previously. I suspect it is related to the fact that you did not connected anything to the process output, although you expected some. (It might help debugging if you save the process and load it with the GUI.)
    Hope this helps (and this time I made a better conclusion :) ), gabor
  • srini
    srini New Altair Community Member
    I am trying to achieve the following

    - I have an process (rmp file) created through GUI, which has all the required operators chained.
    - When I've feeded to the process and ran, it created the required output that I am looking for.
    - Now, I have a model and the test data which I want to test against the model.

    Could you please let me know what is the best approach for the 3rd step to be achieved?

    Thanks,
  • Marco_Boeck
    Marco_Boeck New Altair Community Member
    Hi,

    create a 2nd process via the GUI which concists of an operator to load your data, the "Read Model" operator and the "Apply model" operator. Connect the output of the last operator to the process output and you can get your result via java process execution.

    Regards,
    Marco