MLT Practical 1 and 2
MLT Practical 1 and 2
import pandas as pd
def read_csv(enjoySport.csv):
data = pd.read_csv(enjoySport.csv)
return data
def find_s_algorithm(training_data):
if label.lower() == "yes":
hypothesis = attributes[i].tolist()
break
if label.lower() == "yes":
for j in range(len(hypothesis)):
if hypothesis[j] != attributes[i][j]:
hypothesis[j] = "?"
return hypothesis
def main():
file_path = "training_data.csv"
training_data = read_csv(file_path)
print("Training Data:")
print(training_data)
hypothesis = find_s_algorithm(training_data)
print("\nFinal Most Specific Hypothesis:")
print(hypothesis)
if __name__ == "__main__":
main()
//Elimination algorithm for a given set of training data examples stored in a .CSV file.
import pandas as pd
import numpy as np
def read_csv(enjoysport.csv):
data = pd.read_csv(enjoysport.csv)
return data
def candidate_elimination_algorithm(training_data):
specific_hypothesis = attributes[0].copy()
if label.lower() == "yes":
for j in range(len(specific_hypothesis)):
if specific_hypothesis[j] != attributes[i][j]:
specific_hypothesis[j] = "?"
for j in range(len(specific_hypothesis)):
if specific_hypothesis[j] != attributes[i][j]:
general_hypothesis[j] = specific_hypothesis[j]
else:
general_hypothesis[j] = '?'
file_path = "training_data.csv"
training_data = read_csv(file_path)
print("Training Data:")
print(training_data)
print(specific_h)
print(general_h)
if __name__ == "__main__":
main()