Zaktualizuj 'id3.py'

This commit is contained in:
Cezary Adamczak 2021-05-23 23:16:55 +02:00
parent 4c3da838af
commit 8effe0d702

8
id3.py
View File

@ -54,9 +54,6 @@ def E(cases, attribute):
e = 0 e = 0
values = [] values = []
index = cases[0].attributes.index(attribute) index = cases[0].attributes.index(attribute)
print(attribute)
print(cases[0].values)
print(index)
for case in cases: for case in cases:
if case.values[index] not in values: if case.values[index] not in values:
values.append(case.values[index]) values.append(case.values[index])
@ -83,17 +80,12 @@ def treelearn(cases, attributes, default_class):
t = Node(A) t = Node(A)
new_default_class = count_classes(cases) new_default_class = count_classes(cases)
print(attributes, end=" ")
values = [] values = []
index = attributes.index(A) index = attributes.index(A)
print(index)
for case in cases: for case in cases:
if case.values[index] not in values: if case.values[index] not in values:
values.append(case.values[index]) values.append(case.values[index])
print(values, end="")
print(A)
for value in values: for value in values:
new_cases = [] new_cases = []
for case in cases: for case in cases: