Skip to Content

Contingency Table Fit

Context

The Contingency Table Fit is available to be plotted within the Curve window as part of the Structural Coefficient Analysis. Contingency Table Fit (CTF) measures the quality of the representation of the Joint Probability Distribution by a Bayesian network BB in comparison to a complete (i.e., fully-connected) network CC and a fully-unconnected network UU.

BayesiaLab’s CTF is formally defined as:

CB=100×HU(D)−HB(D)HU(D)−HC(D){C_B} = 100 \times \frac{{{H_U}({\cal D}) - {H_B}({\cal D})}}{{{H_U}({\cal D}) - {H_C}({\cal D})}}

where:

  • HU(D){{H_U}({\cal D})} is the entropy of the data with the unconnected network UU.
  • HB(D){{H_B}({\cal D})} is the entropy of the data with the evaluated network BB.
  • HC(D){{H_C}({\cal D})} is the entropy of the data with the complete (i.e., fully-connected) network CC.

In the complete network, all nodes are directly connected to all other nodes. Therefore, the complete network CC is an exact representation of the chain rule. As such, it does not utilize any conditional independence assumptions for representing the Joint Probability Distribution.

As such, the CTF is an excellent measure to examine the relationship between complexity and data representation. As with all measures provided by the Structural Coefficient Analysis, the Contingency Table Fit supports you in choosing an appropriate value for the Structural Coefficient.

Usage

To illustrate the Contingency Table Fit measure, we use a sample network that represents the joint probability distribution of physicochemical properties in a specific type of white wine. The dataset, on which this model is based, is available from the UCI Machine Learning Repository .

WhiteWine.xbl
XBL

On this network, we perform a Structural Coefficient Analysis: Menus > Tools > Multi-Run > Structural Coefficient Analysis. We follow the overall workflow introduced in Structural Coefficient Analysis. Given that the Contingency Table Fit is particularly relevant in the context of Unsupervised Learning, we use EQ as the Learning Algorithm and set the Structural Coefficient to a range from 0.05 to 1.

Structural Coefficient Analysis settings for Contingency Table Fit

Open Curve in the Confidence Analysis Report to see the ten coefficients tested.

Loading SVG...
Click to Zoom

The x-axis represents the Structural Coefficient values, and the y-axis shows the Contingency Table Fit computed for each network learned with the corresponding value of the Structural Coefficient. Note that the y-values are normalized to a 0 to 1 range, i.e., the smallest computed Contingency Table Fit is displayed as 0 and the largest value as 1. Hovering over a point shows the normalized CTF value plus the unnormalized CTF value in parentheses.

Interpretation

At a coefficient of 0.15556, the CTF is 48.08%. At 0.57778 it is 43.35%. The lower coefficient allows a more complex network that represents these learning data more closely.

These values need to be understood in context:

  • CBC_B is equal to 100% if the Joint Probability Distribution is represented without any approximation, i.e., the entropy of the evaluated network BB is the same as the one obtained with the complete network CC.
  • CBC_B is equal to 0% if the Joint Probability Distribution is represented by considering that all the variables are independent, i.e., the entropy of the evaluated network BB is the same as the one obtained with the unconnected network UU.
  • CBC_B can also be negative if the parameters of network BB do not correspond to the dataset.

So, in the context of this theoretical 0-100% range, the difference between 48.08% and 43.35% appears fairly substantial. To put these values in an even broader context, we set the Structural Coefficient to an extreme range of 0.01 to 150, and run the Structural Coefficient Analysis again:

Loading SVG...
Click to Zoom

The normalized plot assigns 0 to the lowest CTF observed in this run and 1 to the highest. These endpoints do not, by themselves, establish absolute CTF values of 0% or 100%.

This means that our analysis of the 0.05-to-1 range earlier “zoomed in” on a tiny section of this “big picture.” This “big picture” can give you a sense of “how much traction” a model can gain with regard to a dataset. As in the zoomed-in plot, we can see that adding model complexity (by lowering the Structural Coefficient) does indeed steadily improve the data representation. In other words, the model’s structure can capture regularities in the data and represent them.

So, for choosing an appropriate value of the Structural Coefficient, we are looking for the maximum y-value on a steady slope on the curve while avoiding the explosive growth towards 0, which is indicative of overfitting. This approach is similar to interpreting the Structure/Data Ratio, where we are looking for the inflection point in the curve but have to stay clear of overfitting.

Overfitting

For comparison, a model that is ill-suited to the given dataset would show little improvement in terms of data representation until it reaches the stage of overfitting, at which point the model is fitting noise as opposed to regularities in the data. The following plot illustrates this situation. Here, we perform a Structural Coefficient Analysis on pure noise, i.e., nodes with random distributions:

Loading SVG...
Click to Zoom

In the random-data control, a coefficient of 0.16632 gives an absolute CTF of about 1.19%. Fit rises sharply at the smallest coefficients, where additional model complexity can fit chance patterns.