fixed: always positive outcome; added: 3 new wire colors
This commit is contained in:
parent
2daf6a2f6b
commit
8f85934095
Binary file not shown.
@ -49,8 +49,8 @@ class DecisionTree:
|
|||||||
# fig.savefig("decistion_tree.png")
|
# fig.savefig("decistion_tree.png")
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
dump(self.clf, r'algorithms/learn/decision_tree/decision_tree.joblib')
|
dump(self.clf, 'decision_tree.joblib')
|
||||||
dump(self.vec, r'algorithms/learn/decision_tree/dict_vectorizer.joblib')
|
dump(self.vec, 'dict_vectorizer.joblib')
|
||||||
|
|
||||||
def load(self, clf_file, vec_file):
|
def load(self, clf_file, vec_file):
|
||||||
self.clf = load(clf_file)
|
self.clf = load(clf_file)
|
||||||
@ -85,7 +85,7 @@ class DecisionTree:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
generate_data("training_set.txt", 12000)
|
generate_data("training_set.txt", 4500)
|
||||||
decision_tree = DecisionTree()
|
decision_tree = DecisionTree()
|
||||||
decision_tree.build("training_set.txt", 15)
|
decision_tree.build("training_set.txt", 15)
|
||||||
decision_tree.test()
|
decision_tree.test()
|
||||||
|
Binary file not shown.
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import copy
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from disarming.parameters.hash_function import SeriesHash, SpecificityHash
|
from disarming.parameters.hash_function import SeriesHash, SpecificityHash
|
||||||
@ -77,7 +78,11 @@ class DisarmingHandler:
|
|||||||
|
|
||||||
def choose_wire(self):
|
def choose_wire(self):
|
||||||
dt = DecisionTree(load_from_file=True)
|
dt = DecisionTree(load_from_file=True)
|
||||||
self.chosen_wire = dt.get_answer(self.mine_params)[0]
|
agent_params = copy.deepcopy(self.mine_params)
|
||||||
|
agent_params["series"] = self.recognized_series
|
||||||
|
agent_params["specificity"] = self.recognized_specificity
|
||||||
|
|
||||||
|
self.chosen_wire = dt.get_answer(agent_params)[0]
|
||||||
|
|
||||||
return self.chosen_wire
|
return self.chosen_wire
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@ class Wire(Enum):
|
|||||||
BLUE = 1, "blue"
|
BLUE = 1, "blue"
|
||||||
GREEN = 2, "green"
|
GREEN = 2, "green"
|
||||||
RED = 3, "red"
|
RED = 3, "red"
|
||||||
|
YELLOW = 4, "yellow"
|
||||||
|
WHITE = 5, "white"
|
||||||
|
PURPLE = 6, "purple"
|
||||||
|
|
||||||
|
|
||||||
class TypeHash(Enum):
|
class TypeHash(Enum):
|
||||||
@ -23,10 +26,10 @@ class DangerClassHash(Enum):
|
|||||||
|
|
||||||
|
|
||||||
class SeriesHash(Enum):
|
class SeriesHash(Enum):
|
||||||
TCH_2990TONER = 128, "TCH 2990toner", "T"
|
TCH_2990TONER = 220, "TCH 2990toner", "T"
|
||||||
SWX_5000 = 80, "SWX 5000", "S"
|
SWX_5000 = 168, "SWX 5000", "S"
|
||||||
WORKHORSE_3200 = 30, "WORKHORSE 3200", "W"
|
WORKHORSE_3200 = 94, "WORKHORSE 3200", "W"
|
||||||
FX_500 = 15, "FX 500", "F"
|
FX_500 = 1, "FX 500", "F"
|
||||||
|
|
||||||
|
|
||||||
class IndicatorHash(Enum):
|
class IndicatorHash(Enum):
|
||||||
@ -38,9 +41,9 @@ class IndicatorHash(Enum):
|
|||||||
|
|
||||||
|
|
||||||
class SpecificityHash(Enum):
|
class SpecificityHash(Enum):
|
||||||
ANTI_AIRCRAFT = 55, "anti aircraft", "planes"
|
ANTI_AIRCRAFT = 512, "anti aircraft", "planes"
|
||||||
DEPTH_MINE = 37, "depth mine", "ships"
|
DEPTH_MINE = 256, "depth mine", "ships"
|
||||||
ANTI_TANK = 26, "anti tank", "tanks"
|
ANTI_TANK = 16, "anti tank", "tanks"
|
||||||
|
|
||||||
|
|
||||||
class WeightHash(Enum):
|
class WeightHash(Enum):
|
||||||
@ -60,10 +63,16 @@ MAX_VALUE = max([elem.value[0] for elem in TypeHash]) \
|
|||||||
|
|
||||||
|
|
||||||
def _get_wire_color(hash_sum):
|
def _get_wire_color(hash_sum):
|
||||||
if hash_sum < 0.43 * MAX_VALUE:
|
if hash_sum < 0.20 * MAX_VALUE:
|
||||||
return Wire.BLUE
|
return Wire.BLUE
|
||||||
elif hash_sum <= 0.56 * MAX_VALUE:
|
elif hash_sum <= 0.38 * MAX_VALUE:
|
||||||
return Wire.GREEN
|
return Wire.GREEN
|
||||||
|
elif hash_sum <= 0.50 * MAX_VALUE:
|
||||||
|
return Wire.YELLOW
|
||||||
|
elif hash_sum <= 0.60 * MAX_VALUE:
|
||||||
|
return Wire.WHITE
|
||||||
|
elif hash_sum <= 0.80 * MAX_VALUE:
|
||||||
|
return Wire.PURPLE
|
||||||
else:
|
else:
|
||||||
return Wire.RED
|
return Wire.RED
|
||||||
|
|
||||||
|
@ -71,6 +71,27 @@
|
|||||||
{
|
{
|
||||||
"dark_bg": "#804e46"
|
"dark_bg": "#804e46"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"yellow":
|
||||||
|
{
|
||||||
|
"colours":
|
||||||
|
{
|
||||||
|
"dark_bg": "#7d803e"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"purple":
|
||||||
|
{
|
||||||
|
"colours":
|
||||||
|
{
|
||||||
|
"dark_bg": "#733c78"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"white":
|
||||||
|
{
|
||||||
|
"colours":
|
||||||
|
{
|
||||||
|
"dark_bg": "#7d7d7d"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user