Python Financial Data Mining Chapter 11 Review Question 2 (Clustering) Select the population of each region and the ratio of male to female in the sixth census of the People's Republic of China for K-Means cluster analysis.

1. Topic

Select the population of each region and the ratio of male to female in the sixth census of the People's Republic of China for K-Means cluster analysis.

2. Code

# K取值2
print("step2.1:聚类")
k=2
centroids,clusterAssment=kmeans(dataSetKNN1,k)
print('数据类型:',dataSetKNN1.dtype)
print("step3.1:结果输出:见'图11.2.2.png'")
showCluster_2(dataSetKNN1,k,centroids,clusterAssment)

# K取值3
print("step2.2:聚类")
k=3
centroids,clusterAssment=kmeans(dataSetKNN1,k)
print('数据类型:',dataSetKNN1.dtype)
print("step3.2:结果输出:见'图11.2.3.png'")
showCluster_2(dataSetKNN1,k,centroids,clusterAssment)

3. Result graph

(1) I think there is a problem with this picture, but I can't figure out how to modify it. Wait for subsequent revisions and continue uploading.

(2)

(3) 

 

 

Guess you like

Origin blog.csdn.net/xllzuibangla/article/details/124933931