- 1、本文档共11页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Weka[]EM源代码分析
Weka[28] EM 源代码分析
作者:Koala++/屈伟
EM 算法在 clusterers 下面,提一下是因为我没有想到它竟然在这里,而且它的名字也
太大了点,因为这里它只是与 SimpleKMeans 结合的算法。
引自 Andrew Ng 的 Lecture notes mixtures of Gaussians and the EM algorithm:The
EM-algorithm is also reminiscent of the K-means clustering algorithm, except that instead of
“hard” cluster assignment c(i), we instead have the “soft” assignment w_j^(i). Similar to K-means,
it is also susceptible to local optima, so reinitializing at several different initial parameters may be
a good idea。
Soft 指的是我们猜测是概率,取值在[0,1]区间,相反,“hard”猜测是指单个最好的猜测,
可以取值在 {0,1}或是 {1,…,k}。英文原文: The term “soft” refers to our guesses being
probabilities and taking values in [0,1]; in contrast, a “hard” guess is one that represents a single
best guess( such as taking values in {0,1} or {1,…,k})
下面的图来自 Ng Andrew 和 Bishop Chistopher,第一组图 K-Means 的猜测是两个点,
而第二组图 EM 是对概率的猜测。
另一点是刚才文中提到的,多个初始化点,在代码中也体现了。
Ng 在对 EM 算法收敛证明之后,解释如下:Hence, EM causes the likelihood to converge
monotonically. In our description of the EM algorithm, we said wed run it until convergence.
Given the result that we just showed, one reasonable convergence test would be to check if the
increase in l(theta) between successive iterations is smaller than some tolerance parameter, and to
declare convergence if EM is improving l(theta) too slowly.
从 buildCluster 开始:
if (data.checkForStringAttributes()) {
throw new Exception(Cant handle string attributes!);
}
m_replaceMissing = new ReplaceMissingValues();
Instances instances = new Instances(data);
instances.setClassIndex(-1);
m_replaceMissing.setInputFormat(instances);
data = weka.filters.Filter.useFilter(instances, m_replaceMissing);
instances = null;
m_theInstances = data;
// calculate min and max values for attributes
m_minValues = new double[m_theInstances.numAttributes()];
m_maxValues = new double[m_theInstances.numAttributes()];
for (int i = 0; i m_theInstances.numAttributes(); i++) {
m_minValues[i] = m_maxValues[i] = Double.NaN;
}
for (int i = 0; i m_theInstances.numInstances(
文档评论(0)