ML 3
ML 3
df2=pd.read_csv("C:\\Users\\DELL\\OneDrive\Desktop\lab3.csv",header=None)
print("\n The given training data set \n")
print(df2)
print("\n the most general hypothesis:['?','?','?','?','?','?']\n")
print("\n the most specific hypothesis:['0','0','0','0','0','0']\n")
import numpy as np
x=np.array(df2.iloc[0:,:-1])
y=np.array(df2.iloc[0:,-1])
print(x)
print("\n")
print(y)
m,n=x.shape
print("\n")
print(m,n)
print("\n the initial value of hypothesis: ")
hypo=['0']*(n-1)
print("\n Find S: finding a maximally specific hypothesis \n")
print(x)
for i in range(0,m):
if y[i]=='yes':
for j in range(0,n):
if x[i][j]!=hypo[j]:
if hypo[j]=='0':
hypo=x[i,:n]
else:
hypo[j]='?'
print("the hypothesis {0} for training set {0}:".format(i+1),hypo)
print("\n the maximally specific hypothesis for given given training examples:\n")
print(hypo)