Pgr-4

 import pandas as pd
def find_s_algorithm(file_path):
 data = pd.read_csv(file_path)
 print("Training data:")
 print(data)

 attributes = data.columns[:-1] 
 class_label = data.columns[-1] 


 for index, row in data.iterrows():
 if row[class_label] == 'Yes':
  hypothesis = list(row[attributes]) 
  break 

for index, row in data.iterrows():
 if row[class_label] == 'Yes':
  for i, value in enumerate(row[attributes]):
   if hypothesis[i] != value:
     hypothesis[i] = '?' # Generalize hypothesis
return hypothesis

file_path = 'training_data.csv' # Provide the file path
hypothesis = find_s_algorithm(file_path)
print("\nThe final hypothesis is:", hypothesis)

Comments

Popular posts from this blog

Pgr-1

Pgr-5