FIND_S算法逻辑展示

代码展示:
def 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]
#训练样本集
xa = [x2,x3,x4,x1]
h = [ None, None, None, None, None, None ]
for x in xa:
if x[6] == 1:
index = 0
for i in x[:-1]:
if h[index] == None:
h[index] = i
elif h[index] != i:
h[index] = '?'
index += 1
print('规则是:',h)
if __name__ == '__main__':
find_s()
运行结果
