Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- with open("enjoysport.csv") as file:
- csvfile= csv.reader(file)
- dataset=[]
- print('The Given Training Data Set\n')
- for i in csvfile:
- dataset.append(i)
- print(i)
- attributes=len(dataset[0])-1
- hypothesis=['0' for _ in range(attributes)]
- print('\nThe Initial value of hypothesis:\n',hypothesis)
- print('\n\nFind S: Finding a Maximally Specific Hypothesis\n')
- h=0
- for data in dataset[1:]:
- if data[6]=='yes':
- if hypothesis[0]=='0':
- hypothesis=data[:attributes]
- for i in range(attributes):
- if hypothesis[i]!=data[i]:
- hypothesis[i]='?'
- print('For Training Instance No: {} the hypothesis is {}'.format(h,hypothesis))
- h+=1
- print('\n\nThe Maximally Specific Hypothesis for a given Training Examples :\n',hypothesis)
Add Comment
Please, Sign In to add comment