ML Practical 2 Worksheet
ML Practical 2 Worksheet
Practical # 2
DESCRIPTION:
1. Training dataset table (input data):
One of the often-used statistical concepts in machine learning is the hypothesis.It is notably employed in
supervised machine learning, where an ML model uses a dataset to train a function that most effectively
translates input to related outputs.
In this code person enjoys sport if weather is sunny, airtemp is warm, wind is strong
for j in range(0,num_attributes):
hypothesis[j]= a[0][j];
print(hypothesis)
a = []
with open('book2.csv', 'r') as csvfile:
next(csvfile)
for row in csv.reader(csvfile):
a.append(row)
for x in a:
print(x)
num_attribute = len(a[0])-1
print("\nThe initial hypothesis is : ")
hypothesis = ['0']*num_attribute
print(hypothesis)
if a[i][num_attribute] == 'yes':
print ("\nInstance ", i+1, "is", a[i], " and is Positive Instance")
hypothesis[j] = a[i][j]
else:
hypothesis[j] = '?'
print("The hypothesis for the training instance", i+1, " is: " ,
hypothesis, "\n")
if a[i][num_attribute] == 'no':
print("The hypothesis for the training instance", i+1, " is: " ,
hypothesis, "\n")