find-s 算法
實現《機器學習》19頁的FIND-S算法。
驗證不同的實例順序
開始于非最特殊假設。
#__author__=lx #__date__=2011.10.18 #__brief__=FIND-S, from 'machine learning' 19def find_s():x1 = [ 'sunny', 'warm', 'nurmal', 'strong', 'warm', 'same' , 1 ]x2 = [ 'sunny', 'warm', 'high', 'strong', 'warm', 'same' , 1 ]x3 = [ 'rainy', 'cold', 'high', 'strong', 'warm', 'change', 0 ]x4 = [ 'sunny', 'warm', 'high', 'strong', 'cool', 'change', 1 ]h = [ None, None, None, None, None, None ]h1 = [ 'sunny', 'cold', 'high', 'strong', 'warm', 'change' ]xa = [ x1, x2, x3, x4 ]xb = [ x2, x3, x4, x1 ]for i in xb:if i[6] == 1:index = 0for j in i[ :-1 ]:if ( h1[index] == None ):h1[index] = jelif ( h1[index] != j ):h1[index] = '?'index += 1for i in h1:print iif __name__ == "__main__":find_s();
轉載于:https://www.cnblogs.com/lxgeek/archive/2011/10/18/2216595.html
總結
- 上一篇: Netbeans自定义mode
- 下一篇: DDOS***类型以及iptables防