Search code examples
rapidminer

Connecting output of script to extract performance


When I use the Execute Script operator, where there is one input arc and this input is of type ExampleSet and I run, for example, the one-line script return operator.getInput(ExampleSet.class), and then connect the output to an Extract Performance operator, which takes an ExampleSet as input, I get an error: Mandatory input missing at port Performance.example set.

My goal is to check a Petri-net for soundness via the Analyse soundness operator that comes with the RapidProm extension, and to take and change the first attribute on the first line to either 0 or 1 depending on whether this string matches "is sound", so I can then use Extract Performance and combine it with other performances using Average.

Is doing this with Execute Script the right way to do it, and if so, how should I fix this error?


Solution

  • Firstly: Don't bother about the error Mandatory input missing at port Performance.example set It will be resolved when you run the model.

    Secondly: It is indeed a bit ugly, the output of the operator that checks the soundness of the model, since it is a very long string that looks like Woflan diagnosis of net "d1cf46bd-15a9-4801-9f02-946a8f125eaf" - The net is sound End of Woflan diagnosis

    You can indeed use the execute script to resolve this :) See the script below! The output is an example set that returns 1 if the model is sound, and 0 otherwise. Furthermore, I like to use some log operators to translate this to a nice table useful for documentation purposes.

    ExampleSet input = operator.getInput(ExampleSet.class);
    
        for (Example example : input) {
        String uglyResult = example["att1"];
        String soundResult = "The net is sound";
        Boolean soundnessCheck = uglyResult.toLowerCase().contains(soundResult.toLowerCase());
        if (soundnessCheck){
            example["att1"] = "1"; //the net is sound :)
        } else {
            example["att1"] = "0"; //the net is not sound!
        }
    }
    return input;
    

    See also the attached example model I created. RapidMiner Setup