Data Clustering
Context
Data Clustering is a type of unsupervised learning algorithm that creates a new node, . Each state of this newly-created node represents a Cluster.
Data Clustering can be used for different purposes:
- For finding observations that appear the same, i.e., have similar values.
- For finding observations that behave the same, i.e., interact similarly with other nodes in the network.
- For representing an unobserved dimension by means of an induced latent Factor.
- For summarizing a set of nodes.
- For compactly representing the Joint Probability Distribution.
From a technical perspective, each cluster should be:
- Homogeneous and pure.
- Clearly differentiated from other clusters.
- Stable.
From a functional perspective, all clusters should be:
- Easy to understand.
- Operational.
- A fair representation of the data.
Data Clustering with Bayesian networks is typically based on a Naive Bayes structure, in which the newly-created latent Factor Node is the parent of the so-called Manifest Nodes.
- latent (adjective): (of a quality or state) existing but not yet developed or manifest; hidden or concealed.
- manifest (adjective): clear or obvious to the eye or mind.
Because this variable is hidden (i.e., 100% missing values), the marginal probability distribution of and the conditional probability distributions of the Manifest variables are initialized with random distributions. Thus, an Expectation-Maximization (EM) algorithm is used to fit these distributions with the data:
- Expectation: the network is used with its current distributions to compute the posterior probabilities of for the entire set of observations described in the data set. These probabilities are used for soft-imputing .
- Maximization: based on these imputations, the distributions of the network are updated via Maximum Likelihood. The algorithm goes back to Expectation until no significant changes occur to the distributions.
Usage
You can either select a subset of nodes to be included in Data Clustering, or leave all nodes unselected. In the latter case, all nodes on the Graph Panel will be included for Data Clustering.
King County example
The example uses homes with a basement that had been renovated and were at least 100 years old in the sale year. The filter selects 94 of the 21,613 records in the full King County data set. Seven houses were exactly 100 years old. The 94-house CSV already contains the filtered records.
Retain , , , , and . Import all five as continuous variables, then select Equal Frequency with two intervals. The cutoffs from the rebuilt import are 8, 1,820, 1,790, 5,000, and 47.6258, respectively.
Run Data Clustering
Select Menus > Learning > Clustering > Data Clustering. Set automatic selection from two to five states, minimum cluster purity to 80%, minimum cluster size to 5%, and 100 trials on all 94 records. Enable Fixed Seed and enter 31. Leave Meta-Clustering, Multinet, and Create Cluster with Ordered Numerical States off for this run.
Read the result
BayesiaLab selected three clusters. The report shows an obtained score of 4.2985, average cluster purity of 96.4558%, and Contingency Table Fit of 84.2726%. The induced factor connects to all five manifest variables.
Choose Mapping in the report to view the cluster positions. The size of each circle represents the cluster’s marginal probability. Color intensity represents its purity.
Two trial results had three clusters and 88 had two. The remaining entries in the report were nine with one cluster and one with zero clusters. These are trial summaries. The obtained score above refers to the finalized network.
View all 100 trial results
To compare the profiles of the three clusters, set the induced factor as the Target Node. Enter Validation Mode and select Menus > Analysis > Report > Target > Posterior Mean Analysis, then click Radar Chart. The chart compares the normalized means of the five manifest variables across the clusters and with the prior.
Meta-Clustering
Meta-Clustering combines several high-scoring trial solutions. BayesiaLab imputes a factor for each selected solution and clusters the resulting factors.
On the same 94 houses, enable Meta-Clustering and set Used Clusters (%) to 10. Keep the other settings from the standard run. In the standard run, the ten highest-ranked trials included two three-cluster solutions and eight two-cluster solutions.
The final Meta-Clustering solution has two clusters and an average purity of 94.8473%. The clusters account for 67.0213% and 32.9787% of the model’s marginal probability. The radar chart shows how the two clusters differ across the manifest variables.
Multinet
As stated in the Context, Data Clustering with Bayesian networks is typically done with Expectation-Maximization (EM) on a Naive structure. Thus, it is based on the hypothesis that the Manifest variables are conditionally independent of each other given . Therefore, the Naive structure is well suited for finding observations that look the same (1st purpose), but not so good for finding observations that behave similarly (2nd purpose). The behavior should be represented by direct relationships between the Manifest variables.
Multinet clustering is an EM2 algorithm based both on a Naive structure (look) and on a set of Maximum Weight Spanning Trees (MWST) (behavior). Once the distributions of the Naive are randomly set, the algorithm works as follows:
- Expectation_Naive: the Naive network is used with its current distributions for computing the posterior probabilities of , for the entire set of observations described in the data set. These probabilities are used for hard-imputing , i.e., choosing the state with the highest posterior probability;
- Maximization_MWST: is used as a breakout variable. An MWST is learned on each subset of data.
- Expectation_MWST: the joint probabilities of the observations are computed with each MWST and used for updating the imputation of .
- Maximization_Naive: based on this updated imputation, the distributions of the Naive network are updated via Maximum-Likelihood. Then, the algorithm goes back to Expectation_Naive until no significant changes occur to the distributions.
The Look Weight and Behavior Weight parameters allow changing the look/behavior equilibrium. They can be considered as probabilities to run the Naive and MWST steps at each iteration.
Setting Behavior Weight to 0 defines a Data Clustering quite similar to the usual one (EM), but based on hard imputation instead of soft imputation.
King County Multinet example
On the same 94 houses, turn off Meta-Clustering, enable Multinet, and set Look Weight and Behavior Weight to 1. Keep the settings from the standard run.
This run returns five clusters, with an obtained score of 4.2246 and an average purity of 95.3979%. The network uses dashed links to show that the relationships depend on the selected cluster.
The radar chart shows differences in normalized means across the five clusters.
Heterogeneity Weight
The assumption that the data is homogeneous, given all the Manifest Variables, can sometimes be unrealistic. There may be significant heterogeneity in the data across unobserved groups, and it can bias the machine-learned Bayesian networks. This phenomenon is known as Unobserved Heterogeneity, i.e. an unobserved variable in the data set.
Data Clustering represents a solution for searching for such hidden unobserved groups (3rd purpose). However, whereas the default scoring function in Data Clustering is based on the entropy of the data, finding heterogeneous groups requires modifying the scoring function.
We thus defined a Heterogeneity Index :
with
where:
- is the induced Factor,
- are the states of the Factor, i.e. the segments used to split the data,
- is the marginal probability of state , i.e. the relative size of the segment,
- is the set of Manifest variables,
- is the entire data set,
- is the subset of the data that corresponds to the segment
- is the Mutual Information between a Manifest variable and the Target Node , computed on the data set .
The Heterogeneity Weight allows setting a weight of the Heterogeneity Index in the score, which will, therefore, bias the selection of the solutions toward segmentations that maximize the Mutual Information of the Manifest variables with the Target Node.
King County heterogeneity example
Use the 21,613 records in the full King County data set. Compute as the sale year minus the year built, and divide sale price by 1,000 for . Keep discrete and import the five other columns as continuous. Apply R²–GenOpt with seven intervals and a minimum interval weight of 5%. Use these variables:
- : indicates if the house has been renovated
- : Age of the house
- : Living area field in the King County data
- : Longitude coordinate
- : Latitude coordinate
- : Price of the house.
After setting as a Target Node and selecting all the other variables, we use the following settings for Data Clustering:
The run finds two segments with an average purity of 95.9539% and a Heterogeneity Index of 23.5993%. The weighted sum of mutual information between the five manifest variables and is 23.5993% higher across the two segments than in the full data set.
The Heterogeneity Index is computed on the Manifest variables that are used during the segmentation only. To take other variables into account in the computation of the index, these variables have to be included in the segmentation with a weight of 0 to prevent them from influencing the segmentation.
Random Weights
Node weights are 1 by default. A weight of 0 lets a variable appear in the results without influencing the solution. A weight of 2 counts the variable twice. With a Target Node outside the clustering selection, Mutual Information Weight can weight the variables according to their mutual information with the Target Node.
Enable Random Weights to vary node weights across trials. BayesiaLab reduces the magnitude of these variations as the trials progress.