Association rule mining with modal logic

New building blocks

ModalAssociationRules.WorldMaskType
const WorldMask = BitVector

Vector whose i-th position stores how many times a certain MeaningfulnessMeasure applied on a specific Itemsets is true on the i-th world of multiple instances.

If a single instance is considered, then this acts as a bit mask.

For example, if we consider 5 Kripke structures of a modal dataset, each of which containing 3 worlds, then the WorldMask of an itemset could be [5,2,0], meaning that the itemset is always true on the first world of every instance. In the second world, the same itemset is true on it only for two instances. Considering the third world, then the itemset is never true.

See also Itemset, MeaningfulnessMeasure.

source
Missing docstring.

Missing docstring for initminingstate(::typeof(fpgrowth), ::MineableData). Check Documenter's build log for details.

Meaningfulness measures

In general, we can define new meaningfulness measures by leveraging the following macros.

ModalAssociationRules.@localmeasureMacro
macro localmeasure(measname, measlogic)

Build a generic local meaningfulness measure, levering the optimizations provided by any AbstractMiner.

Arguments

  • measname: the name of the local measure you are defining (e.g., lsupport);
  • measlogic: a lambda function whose arguments are (itemset, data, ith_instance, miner) -

see the note below to know more about this.

Note

When defining a new local measure, you only need to write its essential logic through a lambda function (itemset, X, ith_instance, miner).

In particular, itemset is an Itemset, X is a reference to the dataset, ith_instance is an integer defining on which instance you want to compute the measure, and miner is the AbstractMiner in which you want to save the measure.

Also, miner argument can be used to leverage its miningstate structure. A complete example of the logic behind local support is shown below:

_lsupport_logic = (itemset, X, ith_instance, miner) -> begin
    # vector representing on which world an Itemset holds
    wmask = [
        check(formula(itemset), X, ith_instance, w) for w in allworlds(X, ith_instance)]

    # return the result enriched with more informations, that will eventually will be
    # used if miner's miningstate has specific fields (e.g., :instance_item_toworlds).
    return Dict(
        :measure => count(wmask) / length(wmask),
        :instance_item_toworlds => wmask,
    )
end

See also AbstractMiner, hasminingstate, lsupport, miningstate.

source
ModalAssociationRules.@globalmeasureMacro
macro globalmeasure(measname, measlogic)

Build a generic global meaningfulness measure, levering the optimizations provided by any AbstractMiner.

Arguments

  • measname: the name of the global measure you are defining (e.g., gsupport);
  • measlogic: a lambda function whose arguments are (rule, X, threshold, miner) - see the

note below to know more about this.

Note

When defining a new global measure, you only need to write its essential logic through a lambda function (itemset, X, ith_instance, miner).

In particular, itemset is an Itemset, X is a reference to the dataset and miner is the AbstractMiner in which you want to save the measure.

Also, miner argument can be used to leverage its miningstate structure. A complete example of the logic behind global support is shown below:

_gsupport_logic = (itemset, X, threshold, miner) -> begin
    _measure = sum([
        lsupport(itemset, getinstance(X, ith_instance), miner) >= threshold
        for ith_instance in 1:ninstances(X)
    ]) / ninstances(X)

    # at the moment, no `miningstate` fields in miner are leveraged
    return Dict(:measure => _measure)
end

See also AbstractMiner, hasminingstate, gsupport, miningstate.

source

We already introduced lsupport, gsupport, lconfidence and gconfidence in the Getting started section. Other measures that are already built into the package, are the following; note how they are always organized in both local and global versions.

ModalAssociationRules.lliftFunction
function llift(
    rule::ARule,
    ith_instance::LogicalInstance;
    miner::Union{Nothing,AbstractMiner}=nothing
)::Float64

Compute the local lift for the given rule.

Local lift measures how far from independence are rule's antecedent and consequent on a modal logic instance.

Given an ARule X ⇒ Y, if local lift value is around 1, then this means that P(X ⋃ Y) = P(X)P(Y), and hence, the two Itemsets X and Y are independant. If value is greater than (lower than) 1, then this means that X and Y are dependant and positively (negatively) correlated Itemsets.

If a miner is provided, then its internal state is updated and used to leverage memoization.

See also AbstractMiner, antecedent, ARule, glift, LogicalInstance, llift, Threshold.

source
ModalAssociationRules.lconvictionFunction
function lconviction(
    rule::ARule,
    ith_instance::LogicalInstance;
    miner::Union{Nothing,AbstractMiner}=nothing
)::Float64

Compute the local conviction for the given rule.

Conviction attempts to measure the degree of implication of a rule. It's value ranges from 0 to +∞. Unlike lift, conviction is sensitive to rule direction; like lift, values far from 1 indicate interesting rules.

If a miner is provided, then its internal state is updated and used to leverage memoization.

See also AbstractMiner, antecedent, ARule, LogicalInstance, llift, Threshold.

source