-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_DecisionTree.py
More file actions
45 lines (38 loc) · 1.04 KB
/
my_DecisionTree.py
File metadata and controls
45 lines (38 loc) · 1.04 KB
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
42
43
44
45
from abc import ABC, abstractmethod
class DecisionTree(ABC):
@abstractmethod
def classify(self, instance):
"""
Evaluates the learned decision tree on a single instance.
:return: the classification of the instance
"""
pass
@abstractmethod
def print(self):
"""
Prints the tree in specified format.
"""
pass
@abstractmethod
def rootInfoGain(self, train):
"""
Print the information gain of each attribute as computed from creating the root node for the
given DataSet.
Print each line with one attribute
the Attr_name then a space then the info gain use precision of 5
decimal places in output.
Example:
A1 0.12345
A2 0.45678
A3 0.24890
....
"""
pass
@abstractmethod
def printAccuracy(self, test):
"""
Print the accuracy of the classification for test set with 5 decimal places
Example:
0.12345
"""
pass