-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcandidate.txt
41 lines (29 loc) · 1.05 KB
/
candidate.txt
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
38
39
40
41
import pandas as pd
dataset = pd.read_csv('./enjoysports.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
POSITIVE = 'yes'
specificH = X[0].copy()
generalH = [['?' for i in range(len(X[0]))] for j in range(len(X[0]))]
for i, row in enumerate(X):
if y[i] == POSITIVE:
for j, item in enumerate(row):
if specificH[j] != item:
specificH[j] = '?'
else:
for j, item in enumerate(row):
if specificH[j] != item:
generalH[j][j] = specificH[j]
for i, row in enumerate(generalH):
for j, item in enumerate(row):
if item not in specificH:
generalH[i][j] = '?'
for i in range(generalH.count(['?' for i in range(len(X[0]))])):
generalH.remove(['?' for i in range(len(X[0]))])
print(specificH)
print(generalH)
sky,airtemp,humidity,wind,water,forecast,enjoysport
sunny,warm,normal,strong,warm,same,yes
sunny,warm,high,strong,warm,same,yes
rainy,cold,high,strong,warm,change,no
sunny,warm,high,strong,cool,change,yes