Machine_Learning_Code_Implementation icon indicating copy to clipboard operation
Machine_Learning_Code_Implementation copied to clipboard

EM算法公式问题

Open Emma123456 opened this issue 3 years ago • 1 comments

M步:更新参数值

thetas = np.array([v.sum(0)/v.sum() for v in vs]) 请问EM算法中M步骤的公式依据是什么?

Emma123456 avatar Mar 05 '23 01:03 Emma123456

来件收悉,此前也有读者对此代码做了优化的建议,跟您的方法一样。下半年我们会对全书做大幅度的升级,确保代码尽可能的是一个相对优化的版本。总之,非常感谢您的建议!

鲁伟

WhizZest @.***> 于2024年9月2日周一 18:53写道:

线性判别分析:基于NumPy实现的算法准确率不足的原因

书中提到,基于NumPy实现的算法准确率只有0.85,而sklearn的准确率却达到1.0。 我检查了源码,找到了原因: 在代码清单5-1,计算协方差矩阵的calc_cov函数中,不应该对X和Y做标准化处理,只需要做中心化。 具体来说,就是做如下改动: 修改前:

数据标准化X = (X - np.mean(X, axis=0))/np.std(X, axis=0)Y = X if Y == None else (Y - np.mean(Y, axis=0))/np.std(Y, axis=0)

修改后:

数据中心化X = X - np.mean(X, axis=0)Y = X if Y == None else (Y - np.mean(Y, axis=0))

这样修改之后,准确率就达到1.0,和sklearn一样。

— Reply to this email directly, view it on GitHub https://github.com/luwill/Machine_Learning_Code_Implementation/issues/12#issuecomment-2324432573, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLJD27W7UGD6ZDEDX25PNLZUQ7SLAVCNFSM6AAAAABNQCO2U6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRUGQZTENJXGM . You are receiving this because you are subscribed to this thread.Message ID: <luwill/Machine_Learning_Code_Implementation/issues/12/2324432573@ github.com>

luwill avatar Sep 02 '24 13:09 luwill