Testing generalization viability of clustering method Suppose you have a training set and a testing set. You learn a clustering model (e.g., k-means) from the training set, and then you take the observations from your testing set and put them in the appropriate cluster.
If the clustering you have learned is meaningful for the population that generated the training and testing sets, you would expect the proportion of observations allocated to each cluster to be fairly similar between the sets. For example, suppose that, for the training set, cluster 1 has 20% of the data, cluster 2 has 30% of the data, and cluster 3 has 50% of the data. If, for the testing set, cluster 1 had 80% of the data and cluster 2 and 3 each had 10%, that would suggest that the clustering was not meaningful.
Is there a statistical test or measure one can use to evaluate whether a clustering is meaningful in the sense described above?
I found a similar question that addresses the issue of ascertaining the quality of a clustering using a test set. But it does not consider the issue of cluster proportions.
 A: All k-means does is partition the space.  If you are getting 20% of your data are in one region in the training set, and 80% of the test data are in that region, my first guess is that the data are very differently distributed in the two sets.  Trying again with a different partition might yield better results.  It is possible that you don't have enough data to do what you are trying to do, or that you don't have enough data relative to the dimensionality of your space.  It is also possible that the partition k-means is trying to fit is utterly bogus: k-means more imposes a structure on your data than it fits a structure in your data (consider the examples here: How to understand the drawbacks of K-means, it 'finds' clusters when there aren't any and misses clusters that are there when they aren't the type k-means expects).  
At any rate, what you are describing is straightforward, just use a chi-squared test.  Arbitrarily number your centroids from 1 through k, these become the columns of a table.  You will have two rows, training set and test set.  Count the number of patterns that are assigned to each centroid in each dataset, and write it in the corresponding cell in the table.  Then you can do a chi-squared test on the table.  Here is a made up example:  
#          centroid 1 centroid 2 centroid 3 Sum
# training         20         30         50 100
# test             40          5          5  50
# Sum              60         35         55 150

chisq.test(table)
#   Pearson's Chi-squared test
# X-squared = 50.26, df = 2, p-value = 1.22e-11

