import pandas as pd
import numpy as np
data=pd.read_csv("D:\DSet.csv.csv")
print(data)
concepts=np.array(data.iloc[:,0:-1])
print(concepts)
target=np.array(data.iloc[:,-1])
print(target)
def learn(concepts,target):
    specific_h=concepts[0].copy()
    print("\nInitialization of specific_h and general_h")
    print("\n specific_hyspothesis:",specific_h)
    general_h=[["?"for i in range (len(specific_h))]for i in range (len(specific_h))]
    print("\ngeneric hypothesis:",general_h)
    for i,h in enumerate(concepts):
        print("\ninstance",i+1,"is",h)
        if target[i]=='Yes':
            print("instance is positive")
            for x in range (len(specific_h)):
                if h[x]!=specific_h[x]:
                    specific_h[x]='?'
                    general_h[x][x]='?'
        if target[i]=='No':
            print("instance is negetive")
            for x in range (len(specific_h)):
                if h[x]!=specific_h[x]:
                    general_h[x][x]=specific_h[x]
                else:
                    general_h[x][x]='?'
        print("specific hypothesis after",i+1,"instance is",specific_h)
        print("generic hypothesis after",i+1,"instance is",general_h)
        print("\n")
    indices=[i for i, val in enumerate(general_h)if val==['?','?','?','?','?','?']]
    for i in indices:
        general_h.remove(['?','?','?','?','?','?'])
    return specific_h,general_h
s_final,g_final=learn(concepts,target)
print("final specific_h:",s_final,sep="\n")
print("final generic_h:",g_final,sep="\n")

a=5
for i in range(a):
    print('hi neha')
    print('bye nan')

        