Skip to content
Snippets Groups Projects
Commit 3862b889 authored by johannes bilk's avatar johannes bilk
Browse files

updated some decision tree code

parent b65addb0
No related branches found
No related tags found
1 merge request!17Master
...@@ -10,6 +10,7 @@ from inspect import signature ...@@ -10,6 +10,7 @@ from inspect import signature
from ..utility.progressbar import Progressbar from ..utility.progressbar import Progressbar
from collections import deque from collections import deque
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
import warnings
def saveObjectParameters(obj, saveDict, key): def saveObjectParameters(obj, saveDict, key):
...@@ -225,8 +226,8 @@ class DecisionTree(): ...@@ -225,8 +226,8 @@ class DecisionTree():
""" """
training the tree training the tree
""" """
if not self._impurityMeasure or not self._leafFunction or not self._findSplit: if not self._impurityMeasure or not self._findSplit:
raise AttributeError('some (impurity, leaf func, split algo) have not been set') raise AttributeError('some (impurity or split algo) have not been set')
# set the root node of the tree # set the root node of the tree
id = str(self.id+1).zfill(len(str(self.treeID+1))) id = str(self.id+1).zfill(len(str(self.treeID+1)))
...@@ -245,7 +246,11 @@ class DecisionTree(): ...@@ -245,7 +246,11 @@ class DecisionTree():
make predictions from the trained tree make predictions from the trained tree
""" """
if self._trained is False: if self._trained is False:
raise 'must train the tree before it can make predictions' raise Exception('The tree must be trained before it can make predictions.')
if not self._leafFunction:
warnings.warn("Since no leaf function was defined, the raw leaf values are returned.")
return self.raw(data)
# getting the raw leaf values # getting the raw leaf values
rawPredictions = self.raw(data) rawPredictions = self.raw(data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment