Skip to main content

Extract Macro

Synopsis

This operator can be used to define a single macro which can be used by

%{macro_name}in parameter values of succeeding operators of the current process. The macro value will be derived from the input 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 an existing macro.

Description

This operator can be used to define a single macro 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 the parameter value where 'macro_name' is the name of the macro specified when it was defined. In the Extract Macro operator the macro name is specified by themacro参数。宏将被替换的值strings of parameters by the macro's value. This operator can also be used to re-define an existing macro.

This operator sets the value of a single macro from properties of a given input ExampleSet. This includes properties like the number of examples or number of attributes of the input ExampleSet. Specific data value of the input ExampleSet can also be used to set the value of the macro which can be set using various statistical properties of the input ExampleSet e.g. average, min or max value of an attribute. All these options can be understood by studying the parameters and the attached Example Processes. The Set Macro operator can also be used to define a macro but it does not set the value of the macro from properties of a given input ExampleSet.

Macros

A macro can be considered as a value that can be used by all operators of the current process that come after it 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 Processes to develop a better understanding of 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

example set input

This input port expects an ExampleSet. The macro value will be extracted from this ExampleSet

Output

example set output

给定的ExampleSet作为输入传递without changing to the output through this port. This is usually used to reuse the same ExampleSet in further operators. It is not compulsory to attach this port to any other port, Macro value is set even if this port is left without connections.

Parameters

Macro

This parameter is used to name the macro and can be accessed in succeeding operators of current process by writing the macro name in%{macro_name}format, where 'macro_name' is the name of the macro specified by this parameter.

Macro type

This parameter indicates the way the input ExampleSet should be used to define the macro.

  • number_of_examples: If this option is selected, the macro value is set to the total number of examples in the input ExampleSet.
  • number_of_attributes: If this option is selected, the macro value is set to the total number of attributes in the input ExampleSet.
  • data_value: If this option is selected, the macro value is set to the value of the specified attribute at the specified index. The attribute is specified using theattribute nameparameter and the index is specified using theexample index参数。
  • statistics: If this option is selected, the macro value is set to the value obtained by applying the selected statistical operation on the specified attribute. The attribute is specified using theattribute nameparameter and the statistical operator is selected using thestatistics参数。

Statistics

This parameter is only available when themacro typeparameter is set to 'statistics'. This parameter allows you to select the statistical operator to be applied on the attribute specified by theattribute name参数。

Attribute name

This parameter is only available when themacro typeparameter is set to 'statistics' or 'data value'. This parameter allows you to select the required attribute.

Attribute value

This parameter is only available when themacro typeparameter is set to 'statistics' and thestatisticsparameter is set to 'count'. This parameter is used to specify a particular value of the specified attribute. The macro value will be set to the number of occurrences of this value in the specified attribute. The attribute is specified by theattribute name参数。

Example index

This parameter is only available when themacro typeparameter is set to 'data value'. This parameter allows you to select the index of the required example of the attribute specified by theattribute nameparameter and the optionaladditional macros参数。

Additional macros

This parameter is only available when themacro typeparameter is set to 'data value'. This optional parameter allows you to add an unlimited amount of additional macros. Note that the value for theexample indexparameter is used for all macros in this list.

Extract Macro from Annotation