Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K means 簇中心更新的计算问题 #32

Open
FUTUREEEEEE opened this issue Nov 18, 2021 · 3 comments
Open

K means 簇中心更新的计算问题 #32

FUTUREEEEEE opened this issue Nov 18, 2021 · 3 comments

Comments

@FUTUREEEEEE
Copy link

def cal_groupcenter(group, Xarray):

    center = np.zeros(Xarray.shape[1])
    for i in range(Xarray.shape[1]): #range(4)
        for n in group:
            center[i] += Xarray[n][i]  #计算当前类中第i个特征的数据之和
    center = center / Xarray.shape[0]  #计算各个特征的均值
    return center

作者您好!十分感谢你开源的机器学习代码,受益良多,想请教一下:在上面的函数中,为什么使用center = center / Xarray.shape[0] (簇的和除以总样本个数),而不是center = center / len(group) 即每一簇的中心点的均值应该是该簇的和除以该簇的数目
代码位置如下⬇ 十分感激!

center = center / Xarray.shape[0] #计算各个特征的均值

@JohhnyAngel
Copy link

同样有疑问,我觉得你是对的

def cal_groupcenter(group, Xarray):

    center = np.zeros(Xarray.shape[1])
    for i in range(Xarray.shape[1]): #range(4)
        for n in group:
            center[i] += Xarray[n][i]  #计算当前类中第i个特征的数据之和
    center = center / Xarray.shape[0]  #计算各个特征的均值
    return center

作者您好!十分感谢你开源的机器学习代码,受益良多,想请教一下:在上面的函数中,为什么使用center = center / Xarray.shape[0] (簇的和除以总样本个数),而不是center = center / len(group) 即每一簇的中心点的均值应该是该簇的和除以该簇的数目 代码位置如下⬇ 十分感激!

center = center / Xarray.shape[0] #计算各个特征的均值

同样有疑问并且觉得你的想法是对的

@lingjjcn
Copy link

lingjjcn commented Jul 15, 2022 via email

@YiboZhao624
Copy link

def cal_groupcenter(group, Xarray):

    center = np.zeros(Xarray.shape[1])
    for i in range(Xarray.shape[1]): #range(4)
        for n in group:
            center[i] += Xarray[n][i]  #计算当前类中第i个特征的数据之和
    center = center / Xarray.shape[0]  #计算各个特征的均值
    return center

作者您好!十分感谢你开源的机器学习代码,受益良多,想请教一下:在上面的函数中,为什么使用center = center / Xarray.shape[0] (簇的和除以总样本个数),而不是center = center / len(group) 即每一簇的中心点的均值应该是该簇的和除以该簇的数目 代码位置如下⬇ 十分感激!

center = center / Xarray.shape[0] #计算各个特征的均值

我赞成您的看法,并且我觉得应该将那个分母修改为 group.shape[0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants