Exp 4a
Exp 4a
For a given set of training data examples stored in a .CSV file, implement and
demonstrate the Find-S algorithm to output a description of the set of all hypotheses
consistent with the training examples.
Objectives:
i. To import the dataset
ii. Apply identify values of different attributes in the dataset
iii. Apply the Find-S algorithm on specified dataset
Description:
The algorithm identifies the hypothesis that is scans the each positive instances and draws
the hypothesis from most specific to general.
The algorithm is as follows
Code :
import random
import csv
import pandas as pd
attributes = [['Sunny','Rainy'],
['Warm','Cold'],
['Normal','High'],
['Strong','Weak'],
['Warm','Cool'],
['Same','Change']]
num_attributes = len(attributes)
a = []
print("\n The Given Training Data Set \n")
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)
print("\n The Maximally Specific Hypothesis for a given Training Examples :\n")
print(hypothesis)
Input:
DataSet
The values for the attributes Weather Condition , Temperature,Humidity, Wind Intensity,
Perceived Temperature, Atmospheric Change are listed. The last column suggests for
out_door _activity_suitable as yes or no
Output
The Maximally specific hypothesis H=['Sunny', 'Warm', '?', 'Strong', '?', '?']