Untitled

 avatar
unknown
plain_text
a month ago
1.0 kB
14
Indexable
import pandas as pd
def find_s(training_data):
    num_features=training_data.shape[1]-1
    specific_hypothesis=['0']*num_features
    for index,row in training_data.iterrows():
        if row[num_features]==1:
            for i in range(num_features):
                if specific_hypothesis[i]=='0':
                    specific_hypothesis[i]=row[i]
                elif specific_hypothesis[i]!=row[i]:
                    specific_hypothesis[i]='?'
    return specific_hypothesis


def main():
    filename=input("Enter the path to the training data CSV file")
    try:
        training_data=pd.read_csv(filename,header=None)
    except FileNotFoundError:
        print("Error: File not found.Please check thee file path and try agian")
    except Exception as e:
        print(f"Error loading file:{e}")
        return
    hypothesis=find_s(training_data)
    print("\nTraining Data")
    print(training_data)
    print("\nMost Specific Hypothesis: ")
    print(hypothesis)

if __name__=="__main__":
    main()
Editor is loading...
Leave a Comment