This class implements the structure needed to store implications and the methods associated.
Initialize with an optional name
Creates and initialize a new
ImplicationSet object. It can be done in two ways:
initialize(name, attributes, lhs, rhs)
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,
dgCMatrix), initial LHS of the implications stored and the analogous
The other way is used to initialize the
ImplicationSet object from a
rules object from package
Get the names of the attributes
A character vector with the names of the attributes used in the implications.
Get a subset of the implication set
(integer or logical vector) Indices of the implications to extract or remove. If logical vector, only
TRUE elements are retained and the rest discarded.
ImplicationSet with only the rules given by the
idx indices (if all
idx > 0 and all but
idx if all
idx < 0.
Convert to arules format
ImplicationSet$to_arules(quality = TRUE)
(logical) Compute the interest measures for each rule?
rules object as used by package
Add a precomputed implication set
ImplicationSet object, a
rules object, or a pair
SparseSet objects or
dgCMatrix. The implications to add to this formal context.
Nothing, just updates the internal
Cardinality: Number of implications in the set
The cardinality of the implication set.
TRUE if the set of implications is empty,
Size: number of attributes in each of LHS and RHS
A vector with two components: the number of attributes present in each of the LHS and RHS of each implication in the set.
Compute the semantic closure of a fuzzy set with respect to the implication set
ImplicationSet$closure(S, reduce = FALSE, verbose = FALSE)
SparseSet object) Fuzzy set to compute its closure. Use class
SparseSet to build it.
(logical) Reduce the implications using simplification logic?
(logical) Show verbose output?
reduce == FALSE, the output is a fuzzy set corresponding to the closure of
reduce == TRUE, a list with two components:
closure, with the closure as above, and
implications, the reduced set of implications.
Generate a recommendation for a subset of the attributes
(a vector) Vector with the grades of each attribute (a fuzzy set).
(character vector) Names of the attributes to get recommendation for.
A fuzzy set describing the values of the attributes in
attribute_filter within the closure of
Apply rules to remove redundancies
ImplicationSet$apply_rules( rules = c("composition", "generalization"), batch_size = 25000L, parallelize = FALSE, reorder = FALSE )
(character vector) Names of the rules to use. See
(integer) If the number of rules is large, apply the rules by batches of this size.
(logical) If possible, should we parallelize the computation among different batches?
(logical) Should the rules be randomly reordered previous to the computation?
Currently, the implemented rules are
Nothing, just updates the internal matrices for LHS and RHS.
Convert Implications to Canonical Basis
The canonical basis of implications obtained from the current
Print all implications to text
A string with all the implications in the set.
Export to LaTeX
ImplicationSet$to_latex( print = TRUE, ncols = 1, numbered = TRUE, numbers = seq(self$cardinality()) )
(logical) Print to output?
(integer) Number of columns for the output.
TRUE (default), implications will be numbered in the output.
numbered, use these elements to enumerate the implications. The default is to enumerate 1, 2, ..., but can be changed.
A string in LaTeX format that prints nicely all the implications.
Get internal LHS matrix
A sparse matrix representing the LHS of the implications in the set.
Get internal RHS matrix
A sparse matrix representing the RHS of the implications in the set.
Filter implications by attributes in LHS and RHS
ImplicationSet$filter(lhs = NULL, rhs = NULL, drop = FALSE)
(character vector) Names of the attributes to filter the LHS by. If
NULL, no filtering is done on the LHS.
(character vector) Names of the attributes to filter the RHS by. If
NULL, no filtering is done on the RHS.
(logical) Remove the rest of attributes in RHS?
ImplicationSet that is a subset of the current set, only with those rules which has the attributes in
rhs in their LHS and RHS, respectively.
Compute support of each implication
A vector with the support of each implication
The objects of this class are cloneable with this method.
ImplicationSet$clone(deep = FALSE)
Whether to make a deep clone.
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Build a formal context fc_planets <- FormalContext$new(planets) # Find its implication basis fc_planets$find_implications() # Print implications fc_planets$implications # Cardinality and mean size in the ruleset fc_planets$implications$cardinality() sizes <- fc_planets$implications$size() colMeans(sizes) # Simplify the implication set fc_planets$implications$apply_rules("simplification")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.