Built in data structures
FPTree
ModalAssociationRules.FPTree
— Typemutable struct FPTree
content::Union{Nothing,Item} # Item contained in this node (nothing if root)
parent::Union{Nothing,FPTree} # parent node
const children::Vector{FPTree} # children nodes
count::Integer # number of equal Items this node represents
link::Union{Nothing,FPTree} # link to another FPTree root
end
Fundamental data structure used in FP-Growth algorithm. Essentialy, an FPTree
is a prefix tree where a root-leaf path represent an Itemset
.
Consider the Itemset
s sorted by gsupport
of their items. An FPTree
is such that the common Item
s-prefix shared by different Itemset
s is not stored multiple times.
This implementation generalizes the propositional logic case scenario to modal logic; given two Itemset
s sharing a Item
prefix, the worlds in which they are true is accumulated.
Did you notice? One FPTree structure contains all the information needed to construct an EnhancedItemset
. This is crucial to generate new FPTree
s during fpgrowth algorithm, via building ConditionalPatternBase
s iteratively while avoiding visiting the dataset over and over again.
See also EnhancedItemset
, fpgrowth
, gsupport
, Item
, Itemset
, WorldMask
.
ModalAssociationRules.content
— Methodcontent(fptree::FPTree)::Union{Nothing,Item}
Getter for the Item
(possibly empty) wrapped by fptree
.
ModalAssociationRules.content!
— Methodcontent!(fptree::FPTree, item::Item)
Setter for fptree
's content (the wrapped item).
ModalAssociationRules.parent
— Methodparent(fptree::FPTree)::Union{Nothing,FPTree}
Getter for the parent FPTree
s of fptree
.
ModalAssociationRules.parent!
— Methodparent!(fptree::FPTree, item::Union{Nothing,FPTree})
Setter for fptree
's parent FPTree
.
ModalAssociationRules.children
— Methodchildren(fptree::FPTree)::Vector{FPTree}
Getter for the list of children FPTree
s of fptree
.
ModalAssociationRules.children!
— Methodchildren!(fptree::FPTree, child::FPTree)
Add a new FPTree
to fptree
's children vector.
This method forces the new children to be added: it is a caller's responsability to check whether child
is not already a children of fptree
and, if so, handle the case. This check is performed, for example, in grow!
.
ModalAssociationRules.retrieveleaf
— Functionfunction retrieveleaf(fptree::FPTree)::FPTree
Return a reference to the last node in a list-shaped FPTree
.
See also FPTree
;
Base.count
— MethodBase.count(fptree::FPTree)::Integer
Getter for the fptree
internal counter. Essentially, it represents the number of overlappings Item
which ended up in fptree
node during the building process of the tree itself.
ModalAssociationRules.count!
— Methodcount!(fptree::FPTree, newcount::Integer)
Setter for fptree
's internal counter to a fixed value newcount
.
ModalAssociationRules.addcount!
— Methodaddcount!(fptree::FPTree, newcount::Integer)
Add newcount
to fptree
's internal counter.
ModalAssociationRules.grow!
— Methodfunction grow!(
fptree::FPTree,
itemset::Itemset,
ith_instance::Integer,
miner::AbstractMiner;
htable::Union{Nothing,HeaderTable}=nothing
)
function grow!(
fptree::FPTree,
itemset::EnhancedItemset,
ith_instance::Integer,
miner::AbstractMiner;
htable::Union{Nothing,HeaderTable}=nothing
)
grow!(
fptree::FPTree,
enhanceditemsets::Union{ConditionalPatternBase,Vector{Itemset}},
miner::AbstractMiner;
htable::Union{Nothing,HeaderTable}=nothing
)
Push one or more Itemset
s/EnhancedItemset
to an FPTree
. If an HeaderTable
is provided, it is leveraged to develop internal links.
See also EnhancedItemset
, FPTree
, gsupport
, HeaderTable
, Itemset
.
ModalAssociationRules.link
— Methodlink(fptree::FPTree)::Union{Nothing,FPTree}
Getter for fptree
's next brother FPTree
. fptree
's brotherhood is the set of all the FPTree
whose content is exactly fptree.content
.
ModalAssociationRules.link!
— Methodfunction link!(from::FPTree, to::FPTree)
Establish a link between two FPTree
s. If the starting tree is already linked with something, the already existing link are followed until a new "empty-linked" FPTree
is found.
See also follow
, FPTree
, HeaderTable
.
ModalAssociationRules.follow
— Methodfunction follow(fptree::FPTree)::Union{Nothing,FPTree}
Follow fptree
link to (an internal node of) another FPTree
.
See also FPTree
, HeaderTable
.
ModalAssociationRules.islist
— Methodislist(fptree::FPTree)::Bool
Return true if every subtree in fptree
has exactly 0 or 1 children.
See also FPTree
HeaderTable
ModalAssociationRules.HeaderTable
— Typestruct HeaderTable
items::Vector{Item}
link::Dict{Item,Union{Nothing,FPTree}}
end
Utility data structure used to fastly access FPTree
internal nodes.
ModalAssociationRules.items
— Methoditems(htable::HeaderTable)::Vector{Item}
Getter for the Item
s loaded inside htable
.
See also HeaderTable
, Item
.
ModalAssociationRules.link
— Methodlink(htable::HeaderTable)
link(htable::HeaderTable, item::Item)
Getter for the link structure wrapped by htable
, or one of its specific entry.
The link structure is, essentially, a dictionary associating an Item
to a specific FPTree
.
See also FPTree
, HeaderTable
, Item
, link!
.
ModalAssociationRules.follow
— Methodfunction follow(htable::HeaderTable, item::Item)::Union{Nothing,FPTree}
Follow htable
link to (an internal node of) a FPTree
.
See also FPTree
, HeaderTable
, Item
, link
, link!
.
ModalAssociationRules.link!
— Methodfunction link!(htable::HeaderTable, fptree::FPTree)
Establish a link towards fptree
, follow
ing the entry in htable
corresponding to the content
of fptree
.
See also content
, FPTree
, HeaderTable
.
ModalAssociationRules.checksanity!
— Methodfunction checksanity!(htable::HeaderTable, miner::AbstractMiner)::Bool
Check if htable
internal state is correct, that is, its items
are sorted decreasingly by global support. If items
are already sorted, return true
; otherwise, sort them and return false
.
See also AbstractMiner
, gsupport
, HeaderTable
, items
.
Base.reverse
— MethodBase.reverse(htable::HeaderTable)
Iterator on htable
wrapped Item
s, in reverse order.
See also HeaderTable
, Item
.