mirror of
https://github.com/3x4byte/StreetsignRecognition.git
synced 2025-12-22 01:45:52 +00:00
evaluator with evaluated data
This commit is contained in:
@@ -7,11 +7,12 @@ from classes.feature_vector import FeatureVector
|
||||
|
||||
class DecisionTree:
|
||||
|
||||
def __init__(self, children: dict = {}, parent: Self = None, concept: Concept = Concept.UNKNOWN, depth: int = 0) -> None:
|
||||
def __init__(self, children: dict = {}, parent: Self = None, concept: Concept = Concept.UNKNOWN, depth: int = 0, cycles: int = 3) -> None:
|
||||
self.children: dict = children # (number, DecisionTree)
|
||||
self.parent: Self = parent
|
||||
self.concept: Concept = concept
|
||||
self.depth: int = depth
|
||||
self.cycles: int = cycles
|
||||
|
||||
|
||||
# TODO
|
||||
@@ -55,11 +56,11 @@ class DecisionTree:
|
||||
sub_decision_tree: Self = self.children[feature_value] # get sub decition tree for feature
|
||||
sub_decision_tree._insert(vector)
|
||||
except KeyError:
|
||||
self.children.update({vector.features_list[self.depth]: DecisionTree(concept=vector.concept, parent=self, depth=self.depth+1, children={})})
|
||||
self.children.update({vector.features_list[self.depth]: DecisionTree(concept=vector.concept, parent=self, depth=self.depth+1, children={}, cycles=self.cycles)})
|
||||
|
||||
|
||||
def _finished(self, i: int, num_training_data: int):
|
||||
# TODO implement proper finished condition
|
||||
if i < num_training_data*3:
|
||||
if i < num_training_data*self.cycles:
|
||||
return False
|
||||
return True
|
||||
@@ -80,9 +80,9 @@ class Learner:
|
||||
|
||||
def analyse(self, result, expectedConcept: Concept):
|
||||
sorted_dict_result = {key: value for key, value in sorted(result.items(), reverse=True, key=lambda item: item[1])}
|
||||
for key, amount in sorted_dict_result.items():
|
||||
probability = (amount/self.k_paramter) * 100
|
||||
print(f" Probability of {key} is {probability}%")
|
||||
# for key, amount in sorted_dict_result.items():
|
||||
# probability = (amount/self.k_paramter) * 100
|
||||
# print(f" Probability of {key} is {probability}%")
|
||||
|
||||
if next(iter(sorted_dict_result)) == expectedConcept:
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user