Learn practical skills, build real-world projects, and advance your career
Updated 3 years ago
!pip install jovian --upgrade --quiet
import csv
attributes=[['Sunny','Rainy'],
['Warm','Cold'],
['Normal','High'],
['Strong','Weak'],
['Warm','Cool'],
['Same','Change']]
num_attributes=len(attributes)
a=[]
print("\nThe given Training Data Set\n")
with open('CSVFile.csv','r') as csvFile:
reader=csv.reader(csvFile)
for row in reader:
a.append(row)
print(row)
hypothesis=a[0]
print("\nFind-S: Finding a maximally Specific Hypothesis\n")
for i in range(0,len(a)):
if a[i][-1]=='Yes':
for j in range(0,num_attributes):
if a[i][j] != hypothesis[j]:
hypothesis[j]='?'
print("For training example No:{}".format(i),hypothesis)
print("\nThe final hypothesis is:")
print(hypothesis)
The given Training Data Set
['Sunny', 'Warm', 'Normal', 'Strong', 'Warm', 'Same', 'Yes']
['Sunny', 'Warm', 'High', 'Strong', 'Warm', 'Same', 'Yes']
['Rainy', 'Cool', 'High', 'Strong', 'Warm', 'Change', 'No']
['Sunny', 'Warm', 'High', 'Strong', 'Cool', 'Change', 'Yes']
Find-S: Finding a maximally Specific Hypothesis
For training example No:0 ['Sunny', 'Warm', 'Normal', 'Strong', 'Warm', 'Same', 'Yes']
For training example No:1 ['Sunny', 'Warm', '?', 'Strong', 'Warm', 'Same', 'Yes']
For training example No:2 ['Sunny', 'Warm', '?', 'Strong', 'Warm', 'Same', 'Yes']
For training example No:3 ['Sunny', 'Warm', '?', 'Strong', '?', '?', 'Yes']
The final hypothesis is:
['Sunny', 'Warm', '?', 'Strong', '?', '?', 'Yes']
jovian.commit(project='ml-lab-program-1')
[jovian] Detected Colab notebook...
[jovian] Uploading colab notebook to Jovian...
[jovian] Error: Looks like the notebook is missing output cells, please save the notebook and try jovian.commit again.
[jovian] Capturing environment..
[jovian] Committed successfully! https://jovian.ai/akmalbaig98/ml-lab-program-1