fake_world

ml1

Dec 3rd, 2020 (edited)
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import csv
  2. with open("enjoysport.csv") as file:
  3.   csvfile= csv.reader(file)
  4.   dataset=[]
  5.   print('The Given Training Data Set\n')
  6.   for i in csvfile:
  7.     dataset.append(i)
  8.     print(i)
  9.  
  10. attributes=len(dataset[0])-1
  11. hypothesis=['0' for _ in range(attributes)]
  12.  
  13. print('\nThe Initial value of hypothesis:\n',hypothesis)
  14. print('\n\nFind S: Finding a Maximally Specific Hypothesis\n')
  15. h=0
  16. for data in dataset[1:]:
  17.   if data[6]=='yes':
  18.     if hypothesis[0]=='0':
  19.       hypothesis=data[:attributes]
  20.     for i in range(attributes):
  21.       if hypothesis[i]!=data[i]:
  22.         hypothesis[i]='?'
  23.   print('For Training Instance No: {} the hypothesis is {}'.format(h,hypothesis))
  24.   h+=1
  25.  
  26.  
  27. print('\n\nThe Maximally Specific Hypothesis for a given Training Examples :\n',hypothesis)
  28.  
  29.  
  30.  
Add Comment
Please, Sign In to add comment