49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
import json
|
|
import disarming.parameters.mine_parameters as param
|
|
import os
|
|
import project_constants as const
|
|
|
|
# this module is self contained, used to generate a json file
|
|
DIR_DATA = os.path.join(const.ROOT_DIR, "resources", "data", "decision_tree")
|
|
|
|
|
|
# just to show, how mine parameters works
|
|
def param_presents():
|
|
mine = param.MineParameters()
|
|
print(mine.jsonifyable_dict())
|
|
|
|
json_mine = json.dumps(mine.jsonifyable_dict())
|
|
print(json_mine)
|
|
|
|
new_mine = param.MineParameters(json.loads(json_mine))
|
|
print(new_mine.get_parameters())
|
|
|
|
|
|
def generate_data(file_name: str, lines: int):
|
|
file = open(os.path.join(DIR_DATA, file_name), "w")
|
|
data_set = set()
|
|
|
|
for x in range(100000):
|
|
new_params = json.dumps(param.MineParameters().jsonifyable_dict())
|
|
data_set.add(new_params)
|
|
|
|
for x in range(lines):
|
|
if len(data_set) == 0:
|
|
break
|
|
|
|
random_params = data_set.pop()
|
|
file.write(random_params)
|
|
file.write("\n")
|
|
|
|
del data_set
|
|
|
|
file.close()
|
|
|
|
|
|
def main():
|
|
generate_data("training_set.txt", 20000)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|