Add method comparing survival dt examples attributes

This will be used to check for duplicates when generating decision tree's examples.
This commit is contained in:
Michał Czekański 2020-05-24 17:48:11 +02:00
parent ed58517b82
commit 98f692a6d8

View File

@ -35,4 +35,28 @@ class SurvivalDTExample(DecisionTreeExample):
Attribute(SurvivalAttributesDefinitions.waterDistanceAttrDef, distFromWater),
Attribute(SurvivalAttributesDefinitions.restDistanceAttrDef, distFromRestPlace)]
super().__init__(classification, attributes)
super().__init__(classification, attributes)
def compareAttributes(self, anotherExample) -> bool:
"""
Compares attributes of this example with another example's attributes.
:param anotherExample:
:return: True if attrs are equal, False otherwise
"""
attrsAreEqual = True
if self.hungerVal != anotherExample.hungerVal:
attrsAreEqual = False
elif self.thirstVal != anotherExample.thirstVal:
attrsAreEqual = False
elif self.staminaVal != anotherExample.staminaVal:
attrsAreEqual = False
elif self.distFromFood != anotherExample.distFromFood:
attrsAreEqual = False
elif self.distFromWater != anotherExample.distFromWater:
attrsAreEqual = False
elif self.distFromRestPlace != anotherExample.distFromRestPlace:
attrsAreEqual = False
return attrsAreEqual