|  | ## Execute Script

#### Synopsis

This operator executes arbitrary Groovy scripts.

#### Description

This operator can be used to execute arbitrary Groovy scripts. This basically means that analysts can write their own operators directly within the process by specifiying Java code and / or a Groovy script which will be interpreted and executed during process runtime. For a complete reference of Groovy scripting please refer to http://groovy.codehaus.org/.

In addition to the usual scripting code elements from Groovy, the RapidMiner scripting operator defines some special scripting elements:

- If you use the standard imports, all important types like Example, ExampleSet, Attribute, Operator etc. as well as the most important Java types like collections etc. are automatically imported and can directly be used within the script. Hence, there is no need for importing them in your script. However, you can of course import any other class you want and use this in your script.
- The current operator (the scripting operator for which you define the script) is referenced by `operator`.

Example: `operator.log("text")`

- All operator methods like `log` (see above), accessing the input or the complete process can directly be used by writing a preceding `operator`.

Example: `operator.getProcess()`

- Input of the operator can be retrieved via the input method getInput(Class) of the surrounding operator.

Example: `ExampleSet exampleSet = operator.getInput(ExampleSet.class)`

- You can iterate over examples with the following construct:

`for (Example example : exampleSet) { ... }`

- You can retrieve example values with the shortcut

`String value = example["attribute_name"];` or `double value = example["attribute_name"];`

- You can set example values with `example["attribute_name"] = "value";` or

`example["attribute_name"] = 5.7;`

Note: Scripts written for this operator may access Java code. Scripts may hence become incompatible in future releases of RapidMiner.

#### Input

- input 1:

#### Output

- output 1:

#### Parameters

- script: The script to execute.
- standard imports: Indicates if standard imports for examples and attributes etc. should be automatically generated.

#### ExampleProcess