Class FrequentItems

All Implemented Interfaces:
LogicalOperator, PipelineOperator<RecordPort>, RecordPipelineOperator

public class FrequentItems extends CompositeOperator implements RecordPipelineOperator
Compute the frequent items within the given transactions. Two fields are needed in the input flow: one to identify transactions and another to identify items. A minimum support value must be specified as a percentage of transactions an item must participate in to be considered frequent. An optional label field may also be specified which will be used for display purposes instead of the transaction identifiers.

The main output of this operator is the set of frequent items. Two fields are output, the item field from the input and the frequency count of the item.

The operator also outputs a PMML port that contains an association model. The model will be partially filled in with frequent items and transaction statistics.

  • Constructor Details

    • FrequentItems

      public FrequentItems()
      Default constructor.
    • FrequentItems

      public FrequentItems(String txnFieldName, String itemFieldName, double minSupport)
      Construct with properties.
      Parameters:
      txnFieldName - name of the field containing the transaction identifier
      itemFieldName - name of the field containing the item name
      minSupport - minimum support percentage (must be between 0 and 1)
  • Method Details

    • getInput

      public RecordPort getInput()
      Get the input port of this operator.
      Specified by:
      getInput in interface PipelineOperator<RecordPort>
      Returns:
      input port
    • getOutput

      public RecordPort getOutput()
      Get the output port of this operator.
      Specified by:
      getOutput in interface PipelineOperator<RecordPort>
      Returns:
      output port
    • getModel

      public PMMLPort getModel()
      Get the output PMML model port of this plan operator. The PMML uses the association rules model format. Only some transaction statistics and the frequent items are captured in the model. A rule mining algorithm can add the item sets and association rules.
      Returns:
      PMML model capturing frequent items
    • getTxnFieldName

      public String getTxnFieldName()
      Get the transaction field name property.
      Returns:
      transaction field name
    • setTxnFieldName

      public void setTxnFieldName(String txnFieldName)
      Set the transaction field name property.
      Parameters:
      txnFieldName - transaction field name
    • getItemFieldName

      public String getItemFieldName()
      Get the item field name property.
      Returns:
      item field name
    • setItemFieldName

      public void setItemFieldName(String itemFieldName)
      Set the item field name property.
      Parameters:
      itemFieldName - item field name
    • getMinSupport

      public double getMinSupport()
      Get the minimum support property.
      Returns:
      minimum support percentage
    • setMinSupport

      public void setMinSupport(double minSupport)
      Set the minimum support property.
      Parameters:
      minSupport - minimum support percentage
    • getLabelFieldName

      public String getLabelFieldName()
      Get the optional label field name property.
      Returns:
      label field name
    • setLabelFieldName

      public void setLabelFieldName(String labelFieldName)
      Set the optional label field name property.
      Parameters:
      labelFieldName - label field name
    • compose

      protected void compose(CompositionContext ctx)
      Description copied from class: CompositeOperator
      Compose the body of this operator. Implementations should do the following:
      1. Perform any validation of configuration, input types, etc
      2. Instantiate and configure sub-operators, adding them to the provided context via the method OperatorComposable.add(O)
      3. Create necessary connections via the method OperatorComposable.connect(P, P). This includes connections from the composite's input ports to sub-operators, connections between sub-operators, and connections from sub-operators output ports to the composite's output ports
      Specified by:
      compose in class CompositeOperator
      Parameters:
      ctx - the context