Numerical Formal Concept Analysis (nFCA)

nFCA is a modern unsupervised learning tool for analyzing general numerical data. It accepts either a general numerical data matrix, a distance matrix, or a correlation matrix as input data, and outputs two nFCA graphs, a H-graph and an I-graph that reveal systematic, hierarchical clustering and inherent structure of the data. In the following, all R commands are after the R prompt > and the R output is in blue fonts.

Table of Content
1. Software nFCA
2. How to install the R package nFCA, nfca()
3. How to run nfca()
4. How to install Graphviz
5. How to visualize H- and I-graphs using Graphviz
   5.1 Use Graphviz in a Window's machine
   5.2 Use Graphviz in a Mac
   5.3 Use Graphviz in a Linux or a Mac OS running Macports
6. References

1. Software nFCA

The nFCA package includes a main R code nfca() and a supporting Ruby program implementing the faster concept analysis algorithm [1]. Its output graphs, H and I-graphs are printed out as simple digitized presentations in R, which can be visualized better using Graphiviz outside R. We have tested selected versions of Graphviz. Versions 2.26, 2.30, 2.38 for Mac OS Lion and Window work with this package. Do not use version 2.28, which has a known bug. The detailed instructions for using Graphviz in PC/Mac/Macports/Linux are given in Section 5 below.

2. How to install, load and unload the package nFCA in R

If you do not have Ruby, you will get a warning message. Just install Ruby quickly and run above commands again.

3. How to run nFCA in R

Upload and get help: Consider the build-in example, about relationships among a family and the family with their extended family, friends and others. where H = "husband", W = "wife", D="daughter", S="son", HM = "husband's mom", W1 = "wife's friend", and o="other", etc.

Here is how to use the default "histogram" method and default thresholds to conduct a nFCA:

       " and are generated in the current R working directory"

is the first output. Opening the and files in Graphviz leads to the H-graph and I-graph shown in Figure 1 here:

H-graph.jpg I-graph.jpg
Figure 1: H-graph on the left panel and I-graph on the right panel

The second output includes the following digitized presentation of and (compare them with Figure 1):

These digital H- and I-graph presenations are equivalent to the graphs in Figure 1.

4. How to install Graphviz

Follow the instructions at

5. How to visualize the resulting graphs using Graphviz

5.1 Use Graphviz in a Window's machine

1. Locate the generated nFCA graphs in dot: and, which should be in the current R working directory. 2. Click on Graphviz application and then open H-graph, i.e., in Graphviz.
Figure 2: Opening H-graph in Graphviz
You will see a graph pop out under a default layout engine.
3. Change the layout engine to 'fdp' by going to Graph -> Settings -> in Layout Engine box, choose 'fdp'.

Figure 3: Choosing Layout Engine fdp for H-graph
Now you should see the following H-graph in Graphviz.

Figure 4: nFCA H-graph

4. To visualize the I-graph, after opening I-graph, i.e.,, in Graphviz, set Layout Engine to 'neato'

Figure 5: Choosing Layout Engine neato for I-graph
Then you will see the following I-graph,

Figure 6: nFCA I-graph

5.2 Use Graphviz in a Mac

  1. Find Graphviz in your application folder if it is not on your desktop bar.

  2. Click on Graphviz, and then go to "File" -> "open" to open the folder that contains and

  3. Click on, which will show a display using a default layout engine as in Figure 7.

    Figure 7: H-graph using default layout engine in Mac

  4. Click on "Attributes" on the up left corner shown in Figure 7 and then slide down in the pop-out Attributes window to find the "layout" shown in Figure8.

  5. Click "layout" and gently tab on the right of the word "layout" to bring out a small box that you can type in fdp.

  6. Hit return. Then you should see the following graph in Figure 8, which is equivalent to the H-graph in the left panel of Figure 1.

    Figure 8: H-graph in Mac

  7. Go back to "File" to click on "open" to open "" and then repeat steps 4-6, but type in neato instead of fdp in the layout field, to obtain the I-graph in Figure 9.

    Figure 9: I-graph in Mac

5.3 Use Graphviz in a Linux or a Mac OS running Macports

  1. Locate generated nFCA graphs in dot: and, which should be in the current R directory.

  2. In a Mac running Macports or a Linux machine on which Graphviz is installed, at a Unix prompt in the same directory where the and are, type the following commands to generate graphics outside R:

  3. The resulting H-graph and I-graph can be visualized by any standard graphic viewer software. For example, in Macports or Ubuntu, you may use following commands:

    if you have set a default graphics viewer. If not, you can replace "open" by "xv", "gimp", or "eog", depending on the graphics viewer you have.

6. References

[1] Troy, A. D., Zhang, G.-Q. and Tian, Y. (2007) Faster Concept Analysis. Proceedings of the 15th International Conference on Conceptual Structures (ICCS 2007), 4604, 206-219.

[2] Ma, J. (2010) Contributions to Numerical Formal Concept Analysis, Bayesian Predictive Inference, and Sample Size Determination. PhD thesis, Case Western Reserve University.

[3] Ma, J., Sun, J. and Zhang, G.-Q. (2017) Numerical Formal Concept Analysis (nFCA): a New Systematic Clustering Technique. Under review.