0% found this document useful (0 votes)
24 views3 pages

ML Experiment-1

Uploaded by

Sanket Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

ML Experiment-1

Uploaded by

Sanket Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

EE3CO47 (P) Machine Learning with Python Lab

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 .

Software Required: Python and PyScripter.

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:

Exampl Sky AirTem Humidit Win Wate Forecas EnjoySpor


e p y d r t t
1 sunn warm normal stron warm same yes
y g
2 sunn warm high stron warm same yes
y g
3 rainy cold high stron warm change no
g
4 sunn warm high stron cool change yes
y g

Department of Electrical Engineering


Faculty of Engineering
Medi-Caps University
1
EE3CO47 (P) Machine Learning with Python Lab
Experiment No: -01 Implement and demonstrate the FIND-S algorithm for
finding the most specific hypothesis based on a given set Page 2 of 3
of training data samples. Read the training data from
a .CSV file.

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:

sunny warm normal strong warm same yes


sunny warm high strong warm same yes
rainy cold high strong warm change no
sunny warm high strong cool change yes

Output:

'Sunny', 'Warm', 'Normal', 'Strong', 'Warm', 'Same',True

'Sunny', 'Warm', 'High', 'Strong', 'Warm', 'Same',True

'Rainy', 'Cold', 'High', 'Strong', 'Warm', 'Change',False

Department of Electrical Engineering


Faculty of Engineering
Medi-Caps University
2
EE3CO47 (P) Machine Learning with Python Lab
Experiment No: -01 Implement and demonstrate the FIND-S algorithm for
finding the most specific hypothesis based on a given set Page 3 of 3
of training data samples. Read the training data from
a .CSV file.

'Sunny', 'Warm', 'High', 'Strong', 'Cool','Change',True Maximally Specific set


[['Sunny', 'Warm', '?', 'Strong', '?', '?']]

Find S: Finding a Maximally Specific Hypothesis

For Training Example No:0 the hypothesis is


['sunny', 'warm', 'normal', 'strong', 'warm', 'same']

For Training Example No:1 the hypothesis is


['sunny', 'warm', '?', 'strong', 'warm', 'same']

For Training Example No:2 the hypothesis is


'sunny', 'warm', '?', 'strong', 'warm', 'same']

For Training Example No:3 the hypothesis is


'sunny', 'warm', '?', 'strong', '?', '?']

The Maximally Specific Hypothesis for a given Training Examples:


['sunny', 'warm', '?', 'strong', '?', '?']

Conclusion:

Department of Electrical Engineering


Faculty of Engineering
Medi-Caps University
3

You might also like