Categories

Versions

You are viewing the RapidMiner Studio documentation for version 8.2 - Check here for latest version

Set Macros (RapidMiner Studio Core)

Synopsis

This operator can be used to define multiple macros which can be used by %{macro_name} in parameter values of succeeding operators of the current process. The macro values will NOT be derived from any ExampleSet. A macro can be considered as a value that can be used by all operators of the current process that come after the macro has been defined. This operator can also be used to re-define existing macros.

Description

This operator can be used to define multiple macros which can be used in parameter values of succeeding operators of the current process. Once the macro has been defined, the value of that macro can be used as parameter values in coming operators by writing the macro name in %{macro_name} format in a parameter value where 'macro_name' is the name of the macro specified when the macro was defined. In the Set Macros operator, the macro name and value is specified by the macros parameter. A macro will be replaced in the value strings of parameters by the macro's value. This operator can also be used to re-define existing macros.

This operator sets the value of multiple macros irrespective of any ExampleSet. That is why this operator can also exist on its own i.e. without being connected to any other operator. If you want to create a single macro from properties of a given input ExampleSet, the Extract Macro operator is the right operator.

Macros

A macro can be considered as a value that can be used by all operators of the current process that come after the macro has been defined. Whenever using macros, make sure that the operators are in the correct sequence. It is compulsory that the macro should be defined before it can be used in parameter values. The macro is one of the advanced topics of RapidMiner, please study the attached Example Process to develop a better understanding of macros. The Example Processes of the Extract Macro operator are also useful for understanding the concepts related to the macros.

There are also some predefined macros:

  • %{process_name}: will be replaced by the name of the process (without path and extension)
  • %{process_file}: will be replaced by the file name of the process (with extension)
  • %{process_path}: will be replaced by the complete absolute path of the process file
  • Several other short macros also exist, e.g. %{a} for the number of times the current operator was applied.

Please note that other operators like many of the loop operators (e.g. Loop Values , Loop Attributes) also add specific macros.

Input

  • through (Data Table)

    It is not compulsory to connect any object with this port. Any object connected at this port is delivered without any modifications to the output port. This operator can have multiple inputs. When one input is connected, another through input port becomes available which is ready to accept another input (if any). The order of inputs remains the same. The object supplied at the first through input port of the Set Macros operator is available at the first through output port.

Output

  • through (Data Table)

    Objects that were given as input are passed without changing to the output through this port. It is not compulsory to attach this port to any other port, the macro value is set even if this port is left without connections. The Set Macros operator can have multiple outputs. When one output is connected, another through output port becomes available which is ready to deliver another output (if any). The order of outputs remains the same. The object delivered at the first through input port of the Set Macros operator is delivered at the first through output port

Parameters

  • macrosThis parameter is used to specify the names and values of the macros. Macros can be accessed in succeeding operators of the current process by writing the macro's name in %{macro_name} format, where 'macro_name' is the name of the macro specified in this parameter. Range:

Tutorial Processes

Introduction to the Set Macros operator

This is a very basic process that demonstrates the use of macros and the Set Macros operator. The Set Macros operator is used first of all. Two macros are defined in the macros parameter. They are named 'min' and 'max'. 'min' is given the value 1 and 'max' is given the value 4. Note that this operator is not connected to any other operator; it can exist at its own. Always make sure that the macro is defined before it is used in parameter values.

The 'Golf' data set is loaded using the Retrieve operator. The Filter Example Range operator is applied on it. The first example parameter is set to '%{min}' and the last example parameter is set to '%{max}'. When the process will be executed, '%{min}' and '%{max}' will be replaced with the values of the respective macros i.e. '%{min}' and '%{max}' will be replaced by 1 and 4 respectively. Thus the Filter Examples Range operator will deliver only the first four examples of the 'Golf' data set.

At the end, the Write CSV operator is applied to store the output of the Filter Example Range operator in a CSV file. Note that the csv file parameter is set to 'D:\%{process_name}'. Here '%{process_name}' is a predefined macro which will be replaced by the name of the current process (without file extension). Thus the output of the Filter Example Range operator will be written in a csv file in the D drive of your computer. The name of the file will be the same as the name of this process.