Lab 4
Lab 4
CSV file,
implement and demonstrate the Find-S algorithm to output a
description of the set of all hypotheses consistent with the training
examples.
import random
import csv
num_attributes = 4
a = []
print("\n The Given Training Data Set \n")
with open('D:/ML-LAB/emp.csv', 'r') as csvFile:
reader = csv.reader(csvFile)
for row in reader:
a.append (row)
print(row)
print("\n The initial value of hypothesis: ")
for i in range(0,len(a)):
if a[i][num_attributes]=='Yes':
for j in range(0,num_attributes):
if a[i][j]!=hypothesis[j]:
hypothesis[j]='?'
else :
hypothesis[j]= a[i][j]
print(" For Training Example No :{0} the hypothesis is
".format(i),hypothesis)
OUTPUT
The Given Training Data Set