This class implements the structure needed to store implications and the methods associated.
References
Ganter B, Obiedkov S (2016). Conceptual Exploration. Springer. https://doi.org/10.1007/978-3-662-49291-8
Hahsler M, Grun B, Hornik K (2005). “arules - a computational environment for mining association rules and frequent item sets.” J Stat Softw, 14, 1-25.
Belohlavek R, Cordero P, Enciso M, Mora Á, Vychodil V (2016). “Automated prover for attribute dependencies in data with grades.” International Journal of Approximate Reasoning, 70, 51-67.
Mora A, Cordero P, Enciso M, Fortes I, Aguilera G (2012). “Closure via functional dependence simplification.” International Journal of Computer Mathematics, 89(4), 510-526.
Methods
Method new()
Initialize with an optional name
Usage
ImplicationSet$new(...)Details
Creates and initialize a new ImplicationSet object. It can be done in two ways:
initialize(name, attributes, lhs, rhs)
or initialize(rules)
In the first way, the only mandatory argument is attributes, (character vector) which is a vector of names of the attributes on which we define the implications. Optional arguments are: name (character string), name of the implication set, lhs (a dgCMatrix), initial LHS of the implications stored and the analogous rhs.
The other way is used to initialize the ImplicationSet object from a rules object from package arules.
Method [()
Get a subset of the implication set
Method add()
Add a precomputed implication set
Method closure()
Compute the semantic closure of a fuzzy set with respect to the implication set
Method recommend()
Generate a recommendation for a subset of the attributes
Method apply_rules()
Apply rules to remove redundancies
Usage
ImplicationSet$apply_rules(
rules = c("composition", "generalization"),
batch_size = 25000L,
parallelize = FALSE,
reorder = FALSE
)Arguments
rules(character vector) Names of the rules to use. See
details.batch_size(integer) If the number of rules is large, apply the rules by batches of this size.
parallelize(logical) If possible, should we parallelize the computation among different batches?
reorder(logical) Should the rules be randomly reordered previous to the computation?
Method to_direct_optimal()
Compute the Direct Optimal Basis using optimized C++ algorithms.
Usage
ImplicationSet$to_direct_optimal(
method = c("direct_optimal", "final_ts", "monotonic", "priority"),
verbose = FALSE
)Arguments
method(character) The specific algorithm to run:
"direct_optimal": (Default) The Direct Optimal Saturation-Pruning algorithm."final_ts": Computes Transitive Closure then Prunes (Standard approach)."monotonic": Incremental algorithm maintaining monotonicity."priority": Priority-based refinement algorithm.
verbose(logical) Print verbose output from the C++ backend.
Method print()
Print all implications to text
Method to_latex()
Export to LaTeX
Usage
ImplicationSet$to_latex(
print = TRUE,
ncols = 1,
numbered = TRUE,
numbers = seq(self$cardinality())
)Arguments
print(logical) Print to output?
ncols(integer) Number of columns for the output.
numbered(logical) If
TRUE(default), implications will be numbered in the output.numbers(vector) If
numbered, use these elements to enumerate the implications. The default is to enumerate 1, 2, ..., but can be changed.
Method filter()
Filter implications by attributes in LHS and RHS
Arguments
lhs(character vector) Names of the attributes to filter the LHS by. If
NULL, no filtering is done on the LHS.not_lhs(character vector) Names of the attributes to not include in the LHS. If
NULL(the default), it is not considered at all.rhs(character vector) Names of the attributes to filter the RHS by. If
NULL, no filtering is done on the RHS.not_rhs(character vector) Names of the attributes to not include in the RHS. If
NULL(the default), it is not considered at all.drop(logical) Remove the rest of attributes in RHS?
Method use_hedge()
Sets the hedge to use when computing closures
Usage
ImplicationSet$use_hedge(name = c("globalization", "identity"))Examples
# Build a formal context
fc_planets <- FormalContext$new(planets)
# Find its implication basis
fc_planets$find_implications()
# Print implications
fc_planets$implications
#> Implication set with 10 implications.
#> Rule 1: {no_moon} -> {small, near}
#> Rule 2: {far} -> {moon}
#> Rule 3: {near} -> {small}
#> Rule 4: {large} -> {far, moon}
#> Rule 5: {medium} -> {far, moon}
#> Rule 6: {medium, large, far, moon} -> {small, near, no_moon}
#> Rule 7: {small, near, moon, no_moon} -> {medium, large, far}
#> Rule 8: {small, near, far, moon} -> {medium, large, no_moon}
#> Rule 9: {small, large, far, moon} -> {medium, near, no_moon}
#> Rule 10: {small, medium, far, moon} -> {large, near, no_moon}
# Cardinality and mean size in the ruleset
fc_planets$implications$cardinality()
#> [1] 10
sizes <- fc_planets$implications$size()
colMeans(sizes)
#> LHS RHS
#> 2.5 2.3
# Simplify the implication set
fc_planets$implications$apply_rules("simplification")
#> Processing batch
#> --> Simplification: from 10 to 10 in 0.031 secs.
#> Batch took 0.033 secs.