Evaluating the results of the K-means clustering
Now that you have segmented your clusters with the K-means algorithm, you are ready to perform various analyses using the model you created.
Here is an example query you can run to get the average median house value by cluster:
select avg(median_house_value) as avg_median_house_value, chapter8_kmeans_clustering .get_housing_segment_k3(median_income, latitude, longitude) as cluster from chapter8_kmeans_clustering .housing_prices group by 2 order by 1;
The output will look like this:
Figure 8.12 – Average median house values
You can also run a query to see whether higher median incomes correspond to the same clusters with higher home values. Run the following query:
select avg(median_income) as median_income, chapter8_kmeans_clustering.get_housing_segment_k3( median_income, latitude, longitude) as cluster from chapter8_kmeans_clustering.housing_prices group by 2 order...