wendesi / lihang_book_algorithm Goto Github PK
View Code? Open in Web Editor NEW致力于将李航博士《统计学习方法》一书中所有算法实现一遍
Home Page: http://blog.csdn.net/wds2006sdo/article/category/6314784
致力于将李航博士《统计学习方法》一书中所有算法实现一遍
Home Page: http://blog.csdn.net/wds2006sdo/article/category/6314784
由于候选alpha列表的顺序是从小到大的,所以如果有某个alpha不满足KKT条件,就会一直更新到它满足为止。我把svm.py每一次迭代更新的i1和i2打印出来,发现在很多情况下,i1和i2在5000次迭代里都是同一个下标,或者同两对下标。也就是说,最后只有一两个样本变成支持向量了。这样的训练结果合理吗?是否要随机打乱候选列表比较好?
您好,请问在naive bayes 中train函数
`for i in range(class_num):
for j in range(feature_len):
pix_0 = conditional_probability[i][j][0]
pix_1 = conditional_probability[i][j][1]
probalility_0 = (float(pix_0)/float(pix_0+pix_1))*1000000 + 1
probalility_1 = (float(pix_1)/float(pix_0+pix_1))*1000000 + 1
conditional_probability[i][j][0] = probalility_0
conditional_probability[i][j][1] = probalility_1`
为什么要*1000000+1呢?
同学你好,打扰了,我在aminer项目的消歧代码下找到了你的提问,关于那个代码我有一个问题,不知道同学你这边能否给我提供一些帮助,就是他那个代码的源数据是怎么获得的,是现成的还是需要处理后得到的,我在他的代码下面提问了,还没有回复我,所以想到能否跟你交流一下
你好,看了你关于最大熵模型应用于MNIST数据集上的python代码,有一些不懂的地方想要请教一下。
就是应该如何理解特征函数这个东西。代码中关于82页最下方的期望,x是用的(0_x1,y)这样的特征,但是在计算83页最上方的期望的时候,x又变成了一整个输入向量(0_x1,1_x2,.....).请问这个是为什么呢?
不甚感谢
def _select_two_parameters(self):
'''
按照书上7.4.2选择两个变量
'''
index_list = [i for i in xrange(self.N)]
i1_list_1 = filter(lambda i: self.alpha[i] > 0 and self.alpha[i] < self.C, index_list)
i1_list_2 = list(set(index_list) - set(i1_list_1))
i1_list = i1_list_1
i1_list.extend(i1_list_2)
这部分输出结果i1_list是选择的所有index,没有进行筛选;这部分代码的意义是啥?
而且分出来的i1_list_1中包含的index也是0-N-1,没看懂,求解
你好,
有个小问题想请教下:
在李航书中130页,alpha1_new 和 alpha2_new同时在范围(0, C) 时,b_new = b1_new = b2_new, 否则 b_new = (b1_new + b2_new) / 2。
在你的svm.py 的175-180行,alpha1_new 和 alpha2_new 没有同时判断,alpha1_new 满足条件但alpha2_new不满足条件时,b_new发生错误更新。
还是个新手,不知道判断得是否正确。
感谢!
lihang_book_algorithm/hmm/hmm.py
Line 148 in 41ae6fa
i = 0
while self.Pi[i]<ran or self.Pi[i]<0.0001:
ran -= self.Pi[i]
i += 1
I.append(i)
这个函数中用到的采样方法具体是什么方法, 有什么参考资料可以看的吗?
在代码中,误差E每次仅更新挑出来的那两个index对应的E,但是,在b更新的情况下,其他index对应的E不是也会改变吗?
从 文章 里面来看,如果 error_rate = 0.5 的话,那么 alpha_m =0 造成后续迭代中权重就无法更新了。请问如果这种情况下应该如何处理呢?
谢谢
我在运行hmm.py的时候在最开始就出现下面输出
➜ hmm python hmm.py
1
hmm.py:80: RuntimeWarning: invalid value encountered in double_scalars
return numerator/denominator
hmm.py:66: RuntimeWarning: invalid value encountered in double_scalars
return numerator/denominator
在训练了3轮之后我打印A, B, pi,发现都是np.nan.
我自己也实现了一个hmm.py, 用了numpy. 在开始几轮还出现这种数值快速收敛到0的问题。请问这个有什么好的办法解决吗?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.