-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinds_Algorithm.py
37 lines (28 loc) · 957 Bytes
/
Finds_Algorithm.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import pandas as pd
df=pd.read_csv("https://raw.githubusercontent.com/kapilbhise/ml-lab/main/g.csv")
dataset = df.values.tolist()
print("\nThe Given Data Set \n")
print(df)
# print(dataset)
rows=len(dataset)
columns=len(dataset[0])-1
# print(rows,columns)
print("\nThe initial value of hypothesis: ")
# Initialize the hypothesis
hypothesis = ['phi'] * columns
print(hypothesis)
# training with the first instance
for i in range(0,columns):
hypothesis[i] = dataset[0][i]
# print(hypothesis)
# training the dataset
for i in range(0,rows):
if dataset[i][columns]=='Yes':
for j in range(0,columns):
if dataset[i][j]!=hypothesis[j]:
hypothesis[j]='?'
else :
hypothesis[j]= dataset[i][j]
print("After {0} iteration,the hypothesis is :".format(i),hypothesis)
print("\nHypothesis after training :")
print(hypothesis)