ML Experiment-1
ML Experiment-1
Experiment No: -01 Implement and demonstrate the FIND-S algorithm for
finding the most specific hypothesis based on a given set Page 1 of 3
of training data samples. Read the training data from
a .CSV file.
Aim: Implement and demonstrate the FIND-S algorithm for finding the most specific hypothesis based on
a given set of training data samples. Read the training data from a .CSV file .
Theory:
This Python program that uses numpy to create arrays with the arange and linspace functions.
I've included comments for descriptions and the output results.
Ex:1
Algorithm:
FIND-S Algorithm
1. Initialize h to the most specific hypothesis in H
2. For each positive training instance x
For each attribute constraint ai in h
If the constraint ai is satisfied by x
Then do nothing
Else replace ai in h by the next more general constraint that is satisfied by x
3. Output hypothesis h
Training Example:
Program:
Algorithm:
import csv
with open(‘tennis.csv’, ‘r’) as f:
reader=csv.reader(f)
Your_list=list(reader)
H=[[‘0’, ‘0’, ‘0’, ‘0’, ‘0’]]
for i in your list Print(i)
Ifi[-1]==”True”:
J=0
For x in i:
If x!=”True”
if x != h[0][j] and h[0][j] == '0':
h[0][j] = x
elif x != h[0][j] and h[0][j] != '0':
h[0][j] = '?'
else:
pass j=j+1
print("Most specific hypothesis is")
print(h)
Data Set:
Output:
Conclusion: