Package fim

Class ARule

java.lang.Object
fim.ARule
All Implemented Interfaces:
Serializable, Cloneable, Comparable<ARule>

public class ARule extends Object implements Comparable<ARule>, Cloneable, Serializable
Class for association rules.
Since:
2004.07.06
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
    the antecedent/body of the association rule
    protected int
    the comparison direction for sorting association rules
    protected double
    the value of the additional rule evaluation measure
    protected int
    the consequent/head of the association rule
    protected util.IdMap
    the underlying item base
    protected int
    the (absolute) base support (support of the empty pattern, transaction database size)
    protected int
    the (absolute) support of the body set of the association rule
    protected int
    the (absolute) support of the head item of the association rule
    protected int
    the (absolute) support of the item pattern of the association rule
    protected int
    the number of items in the antecedent/body
    protected double
    the value for sorting association rules
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create an empty association rule.
    ARule(util.IdMap ibase)
    Create an empty association rule.
    ARule(util.IdMap ibase, int[] body, int head, int s_body, int s_pat, int s_head, int s_base, double eval)
    Create an association rule from a head item and a body array.
    ARule(util.IdMap ibase, int[] body, int cnt, int head, int s_body, int s_pat, int s_head, int s_base, double eval)
    Create an association rule from a head item and a body array.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
    addItem(int item)
    Add an item (given by its identifier) to the body/antecedent of the association rule.
    final int
    Add an item (given by its object) to the body/antecedent of the association rule.
    final int
    Add an item (given by its name) to the body/antecedent of the association rule.
    final int
    addItemById(int item)
    Add an item (given by its identifier) to the body/antecedent of the association rule.
    final int
    Add an item (given by its name) to the body/antecedent of the association rule.
    final int
    Add an item (given by its object) to the body/antecedent of the association rule.
    final int
    Compare this rule to another (given as argument) by comparing body items lexicographically.
    final boolean
    Whether this rule's body (antecdent) contains another rule's body (antecedent).
    final boolean
    bodyEquals(int[] items)
    Compare the rule's body to a given item pattern.
    final boolean
    bodyEquals(int[] items, int cnt)
    Compare the rule's body to a given item pattern.
    final boolean
    Whether this rule's body (antecedent) is contained in another rule's body (antecedent).
    final boolean
    bodyIsSubOf(int[] items)
    Whether this rule's body (antecedent) is a subpattern of a given item pattern.
    final boolean
    bodyIsSubOf(int[] items, int cnt)
    Whether this rule's body (antecedent) is a subpattern of a given item pattern.
    final boolean
    Whether this rule's body (antecedent) is a subpattern of another rule's body (antecedent).
    final boolean
    bodyIsSuperOf(int[] items)
    Whether this rule's body (antecedent) is a superpattern of a given item pattern.
    final boolean
    bodyIsSuperOf(int[] items, int cnt)
    Whether this rule's body (antecedent) is a superpattern of a given item pattern.
    final boolean
    Whether this rule's body (antecdent) is a superpattern of another rule's body (antecedent).
    final Object
    Clone this association rule (the item base is maintained, the body array is copied).
    final Object
    clone(boolean iclone)
    Clone this association rule.
    final Object
    clone(boolean iclone, util.IdMap ibase)
    Clone this association rule.
    final Object
    clone(util.IdMap ibase)
    Clone this association rule (the body array is copied).
    clone(util.IdMap ibase, boolean iclone)
    Clone this association rule.
    final int
    Compare this rule to another (given as argument).
    final boolean
    equals(ARule rule)
    Compare an association rule to another (given as argument).
    boolean
    equals(ARule rule, boolean chksupp)
    Compare an association rule to another (given as argument).
    final int
    Get the (absolute) support of the body of the association rule.
    final int
    Get the (absolute) support of the head of the association rule.
    final int
    Get the (absolute) support of the item set of the association rule.
    final int[]
    Get the item array (length fits only after packing).
    final int
    Get the (absolute) support of the empty set (i.e.
    final int[]
    Get the item array (length fits only after packing).
    final int
    getBody(int i)
    Get the identifier of an antecedent item.
    final int
    getBodyItem(int i)
    Get the identifier of an antecedent item.
    final String
    Get the name of an antecedent item.
    final Object
    Get the object of an antecedent item.
    final String
    getBodyName(int i)
    Get the name of an antecedent item.
    final Object
    Get the object of an antecedent item.
    final int
    Get the size of the antecedent (number of items).
    final int
    Get the (absolute) support of the body of the association rule.
    final double
    Get the confidence of the association rule.
    final double
    Get the value of the additional rule evaluation measure.
    final int
    Get the identifier of the consequent item.
    final String
    Get the name of the consequent item.
    Get the object of the consequent item.
    final String
    Get the name of the consequent item.
    final Object
    Get the object of the consequent item.
    final int
    Get the size of the consequent of the rule (either 0 or 1).
    final int
    Get the (absolute) support of the head of the association rule.
    final int
    Get the identifier of the last antecedent item.
    final int
    Get the identifier of the last antecedent item.
    final double
    Get the lift value of the association rule.
    final double
    Get the (relative) support of the body of the association rule.
    final double
    Get the (relative) support of the head of the association rule.
    final double
    Get the (relative) support of the item set of the association rule.
    final int
    Get the size of the rule (total number of items).
    final int
    Get the (absolute) support of the item set underlying the association rule.
    final int
    Compare this rule to another (given as argument) by comparing all head properties: items, support values etc.
    final int
    Compare this rule to another (given as argument) by comparing head items lexicographically.
    final int
    Compare this rule to another (given as argument) by comparing all body and head properties: items, support values etc.
    final int
    Compare this rule to another (given as argument) by comparing body and head items lexicographically.
    final void
    Pack an association rule, i.e., optimize memory usage.
    static ARule
    parse(util.IdMap ibase, InputStream in)
    Parse an association rule.
    static ARule
    parse(util.IdMap ibase, Reader reader)
    Parse an association rule.
    static ARule
    parse(util.IdMap ibase, String desc)
    Parse an association rule.
    static ARule
    parse(util.IdMap ibase, util.Scanner scan)
    Parse an association rule.
    final void
    recode(util.IdMap ibase, int[] map)
    Recode an association rule set to another item base, replacing the item base.
    final void
    setSort(double value, int dir)
    Set sort value and sort direction.
    final void
    setSort(int value, int dir)
    Set sort value and sort direction.
    final void
    Sort the items in the rule body (antecedent).
    final String
    Create a string description.
    final String
    toString(String addinfo)
    Create a string description.
    toString(String isep, String info)
    Create a string description.
    final void
    write(Writer writer)
    Write an association rule.
    final void
    write(Writer writer, String info)
    Write an association rule.
    final void
    write(Writer writer, String isep, String info)
    Write an association rule.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ibase

      protected util.IdMap ibase
      the underlying item base
    • body

      protected int[] body
      the antecedent/body of the association rule
    • size

      protected int size
      the number of items in the antecedent/body
    • s_pat

      protected int s_pat
      the (absolute) support of the item pattern of the association rule
    • s_body

      protected int s_body
      the (absolute) support of the body set of the association rule
    • s_head

      protected int s_head
      the (absolute) support of the head item of the association rule
    • s_base

      protected int s_base
      the (absolute) base support (support of the empty pattern, transaction database size)
    • eval

      protected double eval
      the value of the additional rule evaluation measure
    • sort

      protected double sort
      the value for sorting association rules
    • dir

      protected int dir
      the comparison direction for sorting association rules
  • Constructor Details

    • ARule

      public ARule()
      Create an empty association rule.
      Since:
      2007.03.12 (Christian Borgelt)
    • ARule

      public ARule(util.IdMap ibase)
      Create an empty association rule.
      Parameters:
      ibase - the underlying item base
      Since:
      2007.03.12 (Christian Borgelt)
    • ARule

      public ARule(util.IdMap ibase, int[] body, int head, int s_body, int s_pat, int s_head, int s_base, double eval)
      Create an association rule from a head item and a body array.
      Parameters:
      ibase - the underlying item base
      body - the items in the body of the associaton rule
      head - the item in the head of the associaton rule
      s_body - the absolute support of the rule body
      s_pat - the absolute support of the underlying item set
      s_head - the absolute support of the rule head
      s_base - the absolute support of the empty set
      eval - the evaluation of the association rule
      Since:
      2014.10.23 (Christian Borgelt)
    • ARule

      public ARule(util.IdMap ibase, int[] body, int cnt, int head, int s_body, int s_pat, int s_head, int s_base, double eval)
      Create an association rule from a head item and a body array.
      Parameters:
      ibase - the underlying item base
      body - the items in the body of the associaton rule
      cnt - the number of items in the rule body
      head - the item in the head of the associaton rule
      s_body - the absolute support of the rule body
      s_pat - the absolute support of the underlying item set
      s_head - the absolute support of the rule head
      s_base - the absolute support of the empty set
      eval - the evaluation of the association rule
      Since:
      2014.10.23 (Christian Borgelt)
  • Method Details

    • clone

      public final Object clone()
      Clone this association rule (the item base is maintained, the body array is copied).
      Overrides:
      clone in class Object
      Returns:
      a clone of this association rule
      Since:
      2017.06.20 (Christian Borgelt)
    • clone

      public final Object clone(util.IdMap ibase)
      Clone this association rule (the body array is copied).
      Parameters:
      ibase - the item base to use for the clone
      Returns:
      a clone of this association rule
      Since:
      2017.06.20 (Christian Borgelt)
    • clone

      public final Object clone(boolean iclone)
      Clone this association rule.
      Parameters:
      iclone - whether to clone the body item array
      Returns:
      a clone of this association rule
      Since:
      2017.06.20 (Christian Borgelt)
    • clone

      public final Object clone(boolean iclone, util.IdMap ibase)
      Clone this association rule.
      Parameters:
      iclone - whether to clone the body item array
      ibase - the item base to use for the clone; if null, keep old item base
      Returns:
      a clone of this association rule
      Since:
      2017.06.20 (Christian Borgelt)
    • clone

      public Object clone(util.IdMap ibase, boolean iclone)
      Clone this association rule.
      Parameters:
      ibase - the item base to use for the clone; if null, keep old item base
      iclone - whether to clone the body item array
      Returns:
      a clone of this association rule
      Since:
      2017.06.20 (Christian Borgelt)
    • addItemById

      public final int addItemById(int item)
      Add an item (given by its identifier) to the body/antecedent of the association rule.
      Parameters:
      item - the item identifier
      Returns:
      the index of the new item (in the rule body)
      Since:
      2017.06.29 (Christian Borgelt)
    • addItemByName

      public final int addItemByName(String item)
      Add an item (given by its name) to the body/antecedent of the association rule.
      Parameters:
      item - the name of the item to add
      Returns:
      the index of the new item (in the rule body)
      Since:
      2017.06.29 (Christian Borgelt)
    • addItemByObject

      public final int addItemByObject(Object item)
      Add an item (given by its object) to the body/antecedent of the association rule.
      Parameters:
      item - the object of the item to add
      Returns:
      the index of the new item (in the rule body)
      Since:
      2017.06.29 (Christian Borgelt)
    • addItem

      public final int addItem(int item)
      Add an item (given by its identifier) to the body/antecedent of the association rule.
      Parameters:
      item - the identifier of the item to add
      Returns:
      the index of the new item (in the rule body)
      Since:
      2017.06.29 (Christian Borgelt)
    • addItem

      public final int addItem(String item)
      Add an item (given by its name) to the body/antecedent of the association rule.
      Parameters:
      item - the name of the item to add
      Returns:
      the index of the new item (in the rule body)
      Since:
      2017.06.29 (Christian Borgelt)
    • addItem

      public final int addItem(Object item)
      Add an item (given by its object) to the body/antecedent of the association rule.
      Parameters:
      item - the object of the item to add
      Returns:
      the index of the new item (in the rule body)
      Since:
      2017.06.29 (Christian Borgelt)
    • getBody

      public final int getBody(int i)
      Get the identifier of an antecedent item.
      Parameters:
      i - the index of the antecedent item
      Returns:
      the identifier of the antecedent item with index i
      Since:
      2014.10.03 (Christian Borgelt)
    • getBodyItem

      public final int getBodyItem(int i)
      Get the identifier of an antecedent item.
      Parameters:
      i - the index of the antecedent item
      Returns:
      the identifier of the antecedent item with index i
      Since:
      2017.06.20 (Christian Borgelt)
    • getLastBody

      public final int getLastBody()
      Get the identifier of the last antecedent item.
      Returns:
      the identifier of the last antecedent item
      Since:
      2017.06.20 (Christian Borgelt)
    • getLastBodyItem

      public final int getLastBodyItem()
      Get the identifier of the last antecedent item.
      Returns:
      the identifier of the last antecedent item
      Since:
      2017.06.20 (Christian Borgelt)
    • getBodyName

      public final String getBodyName(int i)
      Get the name of an antecedent item.
      Parameters:
      i - the index of the antecedent item
      Returns:
      the name of the antecedent item with index i
      Since:
      2005.07.06 (Christian Borgelt)
    • getBodyItemName

      public final String getBodyItemName(int i)
      Get the name of an antecedent item.
      Parameters:
      i - the index of the antecedent item
      Returns:
      the name of the antecedent item with index i
      Since:
      2017.06.20 (Christian Borgelt)
    • getBodyObject

      public final Object getBodyObject(int i)
      Get the object of an antecedent item.
      Parameters:
      i - the index of the antecedent item
      Returns:
      the object of the antecedent item with index i
      Since:
      2017.06.20 (Christian Borgelt)
    • getBodyItemObject

      public final Object getBodyItemObject(int i)
      Get the object of an antecedent item.
      Parameters:
      i - the index of the antecedent item
      Returns:
      the name of the antecedent item with index i
      Since:
      2017.06.20 (Christian Borgelt)
    • getBody

      public final int[] getBody()
      Get the item array (length fits only after packing).
      Returns:
      the array of body items
      Since:
      2014.10.03 (Christian Borgelt)
    • getAllBodyItems

      public final int[] getAllBodyItems()
      Get the item array (length fits only after packing).
      Returns:
      the array of body items
      Since:
      2017.06.20 (Christian Borgelt)
    • getSize

      public final int getSize()
      Get the size of the rule (total number of items).
      Returns:
      the size of the rule
      Since:
      2007.03.12 (Christian Borgelt)
    • getBodySize

      public final int getBodySize()
      Get the size of the antecedent (number of items).
      Returns:
      the size of the antecedent
      Since:
      2005.07.06 (Christian Borgelt)
    • getHeadSize

      public final int getHeadSize()
      Get the size of the consequent of the rule (either 0 or 1).
      Returns:
      the size of the consequent of the rule
      Since:
      2017.06.20 (Christian Borgelt)
    • getHead

      public final int getHead()
      Get the identifier of the consequent item.
      Returns:
      the identifier of the consequent item
      Since:
      2014.10.03 (Christian Borgelt)
    • getHeadName

      public final String getHeadName()
      Get the name of the consequent item.
      Returns:
      the name of the consequent item
      Since:
      2005.07.06 (Christian Borgelt)
    • getHeadItemName

      public final String getHeadItemName()
      Get the name of the consequent item.
      Returns:
      the name of the consequent item
      Since:
      2017.06.20 (Christian Borgelt)
    • getHeadObject

      public final Object getHeadObject()
      Get the object of the consequent item.
      Returns:
      the object of the consequent item
      Since:
      2017.06.20 (Christian Borgelt)
    • getHeadItemObject

      public Object getHeadItemObject()
      Get the object of the consequent item.
      Returns:
      the object of the consequent item
      Since:
      2017.06.20 (Christian Borgelt)
    • getSupp

      public final int getSupp()
      Get the (absolute) support of the item set underlying the association rule.
      Returns:
      the (absolute) support of the item set underlying the association rule
      Since:
      2005.07.06 (Christian Borgelt)
    • getAbsSupp

      public final int getAbsSupp()
      Get the (absolute) support of the item set of the association rule.
      Returns:
      the (absolute) support of the item set of the association rule
      Since:
      2005.07.06 (Christian Borgelt)
    • getRelSupp

      public final double getRelSupp()
      Get the (relative) support of the item set of the association rule.
      Returns:
      the (relative) support of the item set of the association rule
      Since:
      2005.07.06 (Christian Borgelt)
    • getBodySupp

      public final int getBodySupp()
      Get the (absolute) support of the body of the association rule.
      Returns:
      the (absolute) support of the body of the association rule
      Since:
      2008.11.03 (Christian Borgelt)
    • getAbsBodySupp

      public final int getAbsBodySupp()
      Get the (absolute) support of the body of the association rule.
      Returns:
      the (absolute) support of the body of the association rule
      Since:
      2008.11.03 (Christian Borgelt)
    • getRelBodySupp

      public final double getRelBodySupp()
      Get the (relative) support of the body of the association rule.
      Returns:
      the (relative) support of the body of the association rule
      Since:
      2008.11.03 (Christian Borgelt)
    • getHeadSupp

      public final int getHeadSupp()
      Get the (absolute) support of the head of the association rule.
      Returns:
      the (absolute) support of the head of the association rule
      Since:
      2014.10.02 (Christian Borgelt)
    • getAbsHeadSupp

      public final int getAbsHeadSupp()
      Get the (absolute) support of the head of the association rule.
      Returns:
      the (absolute) support of the head of the association rule
      Since:
      2014.10.02 (Christian Borgelt)
    • getRelHeadSupp

      public final double getRelHeadSupp()
      Get the (relative) support of the head of the association rule.
      Returns:
      the (relative) support of the head of the association rule
      Since:
      2014.10.02 (Christian Borgelt)
    • getBaseSupp

      public final int getBaseSupp()
      Get the (absolute) support of the empty set (i.e. the size of the transaction database).
      Returns:
      the (absolute) support of the empty set
      Since:
      2016.04.08 (Christian Borgelt)
    • getConf

      public final double getConf()
      Get the confidence of the association rule.
      Returns:
      the confidence of the association rule
      Since:
      2005.07.06 (Christian Borgelt)
    • getLift

      public final double getLift()
      Get the lift value of the association rule.
      Returns:
      the lift value of the association rule
      Since:
      2005.07.06 (Christian Borgelt)
    • getEval

      public final double getEval()
      Get the value of the additional rule evaluation measure.
      Returns:
      the value of the additional rule evaluation measure
      Since:
      2005.07.06 (Christian Borgelt)
    • sort

      public final void sort()
      Sort the items in the rule body (antecedent).
      Since:
      2017.06.20 (Christian Borgelt)
    • setSort

      public final void setSort(int value, int dir)
      Set sort value and sort direction.
      Parameters:
      value - the value to sort association rules on
      dir - the direction to sort association rules into
      Since:
      2016.04.10 (Christian Borgelt)
    • setSort

      public final void setSort(double value, int dir)
      Set sort value and sort direction.
      Parameters:
      value - the value to sort association rules on
      dir - the direction to sort association rules into
      Since:
      2016.04.10 (Christian Borgelt)
    • compareTo

      public final int compareTo(ARule rule)
      Compare this rule to another (given as argument).
      Specified by:
      compareTo in interface Comparable<ARule>
      Parameters:
      rule - the rule to compare to
      Returns:
      -1, 0, or +1 as the sort value of this rule is less than, equal to, or greater than the sort value of the given rule
      Since:
      2016.04.10 (Christian Borgelt)
    • bodyCmpTo

      public final int bodyCmpTo(ARule rule)
      Compare this rule to another (given as argument) by comparing body items lexicographically.
      Parameters:
      rule - the rule to compare to
      Returns:
      -1, 0, or +1 as this rule is less than, equal to, or greater than the rule given as an argument
      Since:
      2016.06.20 (Christian Borgelt)
    • headCmpTo

      public final int headCmpTo(ARule rule)
      Compare this rule to another (given as argument) by comparing head items lexicographically.
      Parameters:
      rule - the rule to compare to
      Returns:
      -2, 0, or +2 as this rule is less than, equal to, or greater than the rule given as an argument
      Since:
      2016.06.29 (Christian Borgelt)
    • itemsCmpTo

      public final int itemsCmpTo(ARule rule)
      Compare this rule to another (given as argument) by comparing body and head items lexicographically.
      Parameters:
      rule - the rule to compare to
      Returns:
      -1 or +1 if the two rules differ in their antecedent/body; -2 or +2 if the two rules have the same antecedent/body, but differ in their consequent/head; and 0 if the two rules coincide in all items; the function returns a negative value, 0, or a positive value as this rule is less than, equal to, or greater than the rule given as an argument
      Since:
      2016.06.20 (Christian Borgelt)
    • headAllCmpTo

      public final int headAllCmpTo(ARule rule)
      Compare this rule to another (given as argument) by comparing all head properties: items, support values etc.
      Parameters:
      rule - the rule to compare to
      Returns:
      -2 or +2 if the two rules differ in their consequent/head; -3 or +3 if the two rules have the same consequents/heads, but differ in their support values; and 0 if the two rules coincide in all items and in all support values; the function returns a negative value, 0, or a positive value as this rule is less than, equal to, or greater than the rule given as an argument
      Since:
      2016.06.20 (Christian Borgelt)
    • itemsAllCmpTo

      public final int itemsAllCmpTo(ARule rule)
      Compare this rule to another (given as argument) by comparing all body and head properties: items, support values etc.
      Parameters:
      rule - the rule to compare to
      Returns:
      -1 or +1 if the two rules differ in their antecedent/body; -2 or +2 if the two rules have the same antecedent, but differ in their consequent/head; -3 or +3 if the two rules coincide in their items, but differ in their support values; and 0 if the two rules coincide in all items and all support values; the function returns a negative value, 0, or a positive value as this rule is less than, equal to, or greater than the rule given as an argument
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyEquals

      public final boolean bodyEquals(int[] items, int cnt)
      Compare the rule's body to a given item pattern.
      Parameters:
      items - the items of the pattern to compare to
      cnt - the number of items; if negative, the length of the item array is used
      Returns:
      whether the rule's body equals the given item pattern
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyEquals

      public final boolean bodyEquals(int[] items)
      Compare the rule's body to a given item pattern.
      Parameters:
      items - the items of the pattern to compare to
      Returns:
      whether the rule's body equals the given item pattern
      Since:
      2016.06.20 (Christian Borgelt)
    • equals

      public final boolean equals(ARule rule)
      Compare an association rule to another (given as argument).
      Parameters:
      rule - the association rule to compare to
      Returns:
      true if the two rules are identical and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • equals

      public boolean equals(ARule rule, boolean chksupp)
      Compare an association rule to another (given as argument).
      Parameters:
      rule - the association rule to compare to
      chksupp - whether to compare the support values
      Returns:
      true if the two rules are identical and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsSubOf

      public final boolean bodyIsSubOf(int[] items, int cnt)
      Whether this rule's body (antecedent) is a subpattern of a given item pattern.

      For item permutations and sequences the function works directly, but for item sets the rule body and the given item array need to be sorted for this function to work.

      Parameters:
      items - the items of the pattern to compare to
      cnt - the number of items; if negative, the length of the given item array is used
      Returns:
      true if this rule's body (antecedent) is a subpattern of the given item pattern and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsSubOf

      public final boolean bodyIsSubOf(int[] items)
      Whether this rule's body (antecedent) is a subpattern of a given item pattern.

      For item permutations and sequences the function works directly, but for item sets the rule body and the given item array need to be sorted for this function to work.

      Parameters:
      items - the items of the pattern to compare to
      Returns:
      true if this rule's body (antecedent) is a subpattern of the given item pattern and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsSubOf

      public final boolean bodyIsSubOf(ARule rule)
      Whether this rule's body (antecedent) is a subpattern of another rule's body (antecedent).

      For item permutations and sequences the function works directly, but for item sets both rule bodies need to be sorted with sort() for this function to work.

      Parameters:
      rule - the association rule to compare to
      Returns:
      true if this rule's body (antecedent) is a subpattern of the body (antecedent) of the given association rule rule and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsContainedIn

      public final boolean bodyIsContainedIn(ARule rule)
      Whether this rule's body (antecedent) is contained in another rule's body (antecedent).

      For item permutations and sequences the function works directly, but for item sets both rule bodies need to be sorted with sort() for this function to work.

      Parameters:
      rule - the association rule to compare to
      Returns:
      true if this rule's body (antecedent) is contained in the body (antecedent) of the given association rule rule and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsSuperOf

      public final boolean bodyIsSuperOf(int[] items, int cnt)
      Whether this rule's body (antecedent) is a superpattern of a given item pattern.

      For item permutations and sequences the function works directly, but for item sets the rule body and the given item array need to be sorted for this function to work.

      Parameters:
      items - the items of the pattern to compare to
      cnt - the number of items; if negative, the length of the given item array is used
      Returns:
      true if this rule's body (antecedent) is a superpattern of the given item pattern and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsSuperOf

      public final boolean bodyIsSuperOf(int[] items)
      Whether this rule's body (antecedent) is a superpattern of a given item pattern.

      For item permutations and sequences the function works directly, but for item sets the rule body and the given item array need to be sorted for this function to work.

      Parameters:
      items - the items of the pattern to compare to
      Returns:
      true if this rule's body (antecedent) is a superpattern of the given item pattern and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyIsSuperOf

      public final boolean bodyIsSuperOf(ARule rule)
      Whether this rule's body (antecdent) is a superpattern of another rule's body (antecedent).

      For item permutations and sequences the function works directly, but for item sets both rule bodies need to be sorted with sort() for this function to work.

      Parameters:
      rule - the association rule to compare to
      Returns:
      true if this rule's body (antecedent) is a superpattern of the body (antecedent) of the given association rule rule and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • bodyContains

      public final boolean bodyContains(ARule rule)
      Whether this rule's body (antecdent) contains another rule's body (antecedent).

      For item permutations and sequences the function works directly, but for item sets both rule bodies need to be sorted with sort() for this function to work.

      Parameters:
      rule - the association rule to compare to
      Returns:
      true if this rule's body (antecedent) contains the body (antecedent) of the given association rule rule and false otherwise
      Since:
      2016.06.20 (Christian Borgelt)
    • recode

      public final void recode(util.IdMap ibase, int[] map)
      Recode an association rule set to another item base, replacing the item base.
      Parameters:
      ibase - the item base to recode the association rule set to
      map - the old identifier to new identifier map; if null, the map is created by a call to IdMap.getMapTo()
      Since:
      2016.06.29 (Christian Borgelt)
    • pack

      public final void pack()
      Pack an association rule, i.e., optimize memory usage.
      Since:
      2005.07.06 (Christian Borgelt)
    • write

      public final void write(Writer writer) throws IOException
      Write an association rule.
      Parameters:
      writer - the writer to write to
      Throws:
      IOException - if a write error occurs
      Since:
      2016.04.08 (Christian Borgelt)
    • write

      public final void write(Writer writer, String info) throws IOException
      Write an association rule.
      Parameters:
      writer - the writer to write to
      info - the additional information to write
      Throws:
      IOException - if a write error occurs
      Since:
      2016.04.08 (Christian Borgelt)
    • write

      public final void write(Writer writer, String isep, String info) throws IOException
      Write an association rule.
      Parameters:
      writer - the writer to write to
      isep - the item separator
      info - the additional information to write
      Throws:
      IOException - if a write error occurs
      Since:
      2016.04.08 (Christian Borgelt)
    • parse

      public static ARule parse(util.IdMap ibase, util.Scanner scan) throws IOException
      Parse an association rule.
      Parameters:
      ibase - the underlying item base
      scan - the scanner to read from
      Returns:
      the parsed association rule
      Throws:
      IOException - if a read error occurs
      Since:
      2005.07.06 (Christian Borgelt)
    • parse

      public static ARule parse(util.IdMap ibase, Reader reader) throws IOException
      Parse an association rule.
      Parameters:
      ibase - the underlying item base
      reader - the reader to read from
      Returns:
      the parsed association rule
      Throws:
      IOException - if a read error occurs
      Since:
      2005.07.06 (Christian Borgelt)
    • parse

      public static ARule parse(util.IdMap ibase, String desc) throws IOException
      Parse an association rule.
      Parameters:
      ibase - the underlying item base
      desc - the string description to parse
      Returns:
      the parsed association rule
      Throws:
      IOException - if a read error occurs
      Since:
      2005.07.06 (Christian Borgelt)
    • parse

      public static ARule parse(util.IdMap ibase, InputStream in) throws IOException
      Parse an association rule.
      Parameters:
      ibase - the underlying item base
      in - the input stream to read from
      Returns:
      the parsed association rule
      Throws:
      IOException - if a read error occurs
      Since:
      2005.07.06 (Christian Borgelt)
    • toString

      public String toString(String isep, String info)
      Create a string description.
      Parameters:
      isep - the separator for the items
      info - the additional rule information to write
      Returns:
      the created string description
      Since:
      2017.06.20 (Christian Borgelt)
    • toString

      public final String toString(String addinfo)
      Create a string description.
      Parameters:
      addinfo - the additional rule information to write
      Returns:
      the created string description
      Since:
      2017.06.20 (Christian Borgelt)
    • toString

      public final String toString()
      Create a string description.
      Overrides:
      toString in class Object
      Returns:
      the created string description
      Since:
      2005.07.06 (Christian Borgelt)