导入数据
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
ageinc_df=pd.read_csv(‘w3_ageinc.csv’)
ageinc_df.info()
#两列数据,年龄与收入
聚类分析案列代码
ageinc_df.describe()
聚类分析案列代码
聚类分析案列代码
#现在进行聚类分析

from sklearn import cluster
model=cluster.KMeans(n_clusters=3,random_state=10)
model.fit(ageinc_df[[‘z_income’,‘z_age’]])
#导入sklearn中的cluster
#将群体分成3层
#用标准化的收入与年龄来拟合模型

聚类分析案列代码

聚类分析案列代码
聚类分析案列代码
#将用户分为6层
聚类分析案列代码
聚类分析案列代码
聚类分析案列代码

相关文章:

猜你喜欢
  • 2022-12-23
  • 2021-09-17
  • 2021-05-29
  • 2021-04-12
  • 2021-04-15
相关资源
相似解决方案