knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The aim of this package is to provide tools to perform fuzzy formal concept analysis (FCA) from within R. It provides functions to load and save a Formal Context, extract its concept lattice and implications. In addition, one can use the implications to compute semantic closures of fuzzy sets and, thus, build recommendation systems.
The fcaR package provides data structures which allow the user to work seamlessly with formal contexts and sets of implications. More explicitly, three main classes are implemented, using the \code{R6} object-oriented-programming paradigm in R:
Two additional helper classes are implemented:
Since fcaR is an extension of the data model in the arules package, most of the methods and classes implemented interoperates with the main S4 classes in arules (transactions and rules).
This package is available at CRAN, so its stable version can be easily installed using:
install.packages("fcaR")
The development version of this package can be installed with
remotes::install_github("neuroimaginador/fcaR", build_vignettes = TRUE)
or
remotes::install_github("Malaga-FCA-group/fcaR", build_vignettes = TRUE)
Let us start with a fuzzy dataset (stored in a matrix I) as follows:
library(fcaR) objects <- paste0("O", 1:6) n_objects <- length(objects) attributes <- paste0("P", 1:6) n_attributes <- length(attributes) I <- matrix(data = c(0, 1, 0.5, 0, 0, 0.5, 1, 1, 0.5, 0, 0, 0, 0.5, 1, 0, 0, 1, 0, 0.5, 0, 0, 1, 0.5, 0, 1, 0, 0, 0.5, 0, 0, 0, 0, 1, 0, 0, 0), nrow = n_objects, byrow = FALSE) colnames(I) <- attributes rownames(I) <- objects knitr::kable(I, format = "html", booktabs = TRUE)
Here, a value $x$ in the intersection of a row and a column indicates that the object of the corresponding row possesses the attribute in the column in a degree of at least $x$ (if $x = 0$, the attribute is absent in the object, and if $x = 1$, the attribute is fully present in the object).
We can build a FormalContext object:
fc <- FormalContext$new(I) print(fc)
With a single function, we can compute the set of concepts:
# Compute all concepts fc$find_concepts() # The first concept fc$concepts$sub(1) # And plot the concept lattice fc$concepts$plot()
We can also extract implications from the formal context:
# Extract implications fc$find_implications() # Which implications have been extracted fc$implications
Some fundamental functionalities on the concept lattice associated to the formal context have been implemented:
Also, one can compute the support of both implications and concepts:
fc$implications$support() fc$concepts$support()
In this package, we have implemented a logic to manage implications. This so-called Simplification Logic allows us to simplify the extracted rules by removing redundancies, as well as computing the closure of a given fuzzy attribute set.
# Reduce the number of implications using two simple # rules. The algorithm applies the specified rules # in batches, if the number of rules is high. fc$implications$apply_rules(rules = c("composition", "generalization")) # Reduced set of implications fc$implications
All these functions work natively with fuzzy and with binary datasets.
For more details on the methods implemented and further examples, see the vignettes in this package.
With respect to the CRAN version, the development version has the following changes.
Enhancements:
fc$scale()
function admits a new argument bg
(default: FALSE) which, if set to TRUE, avoids computing the background knowledge of the scales.Enhancements:
fc$use_logic()
to select one of the available_logics()
.Bugfixes:
Bugfixes:
Enhancements:
New functionality:
Bugfixes:
Guigues J, Duquenne V (1986). “Familles minimales d'implications informatives résultant d'un tableau de données binaires.” Mathématiques et Sciences humaines, 95, 5-18.
Ganter B, Wille R (1999). Formal concept analysis : mathematical foundations. Springer. ISBN 3540627715.
Cordero P, Enciso M, Mora Á, Pérez de Guzman I (2002). “SLFD Logic: Elimination of Data Redundancy in Knowledge Representation.” Advances in Artificial Intelligence - IBERAMIA 2002, 2527, 141-150. doi: 10.1007/3-540-36131-6_15 (URL: https://doi.org/10.1007/3-540-36131-6_15).
Belohlavek R (2002). “Algorithms for fuzzy concept lattices.” In Proc. Fourth Int. Conf. on Recent Advances in Soft Computing. Nottingham, United Kingdom, 200-205.
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.
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.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.