if you remember our discussion earlier on cluster labelsthey are just indicators used to distinguish data points from each other based on which cluster or group they fall into hence we cannot compare cluster with label directly with true class label it is possible that all data points with true class label of were actually clustered with label during the clustering process based on thiswe can leverage several metrics to validate clustering performance when we have the true labels available three popular metrics can be used in this scenariohomogeneitya clustering model prediction result satisfies homogeneity if all of its clusters contain only data points that are members of single class (based on the true class labelscompletenessa clustering model prediction result satisfies completeness if all the data points of specific ground truth class label are also elements of the same cluster -measurethe harmonic mean of homogeneity and completeness scores gives us the -measure value values are typically bounded between and and usually higher values are better let' compute these metric on our two -means clustering models km _hcv np round(metrics homogeneity_completeness_v_measure(ykm _labels) km _hcv np round(metrics homogeneity_completeness_v_measure(ykm _labels) print('homogeneitycompletenessv-measure metrics for num clusters= 'km _hcvprint('homogeneitycompletenessv-measure metrics for num clusters= 'km _hcvhomogeneitycompletenessv-measure metrics for num clusters= homogeneitycompletenessv-measure metrics for num clusters= we can see that the -measure for the first model with two clusters is better than the one with five clusters and the reason is because of higher completeness score another metric you can try out includes the fowlkes-mallows score internal validation internal validation means validating clustering model by defining metrics that capture the expected behavior of good clustering model good clustering model can be identified by two very desirable traitscompact groupsi the data points in one cluster occur close to each other well separated groupsi two groups\clusters have as large distance among them as possible we can define metrics that mathematically calculate the goodness of these two major traits and use them to evaluate clustering models most of such metrics will use some concept of distance between data points the distance between data points can be defined using any candidate distance metric ranging from euclidian distancemanhattan distanceor any metric that meets the criteria for being distance metric