This commit is contained in:
s464859 2022-06-09 17:14:14 +02:00
parent 480401f8fd
commit bb0d847ea1
3 changed files with 34 additions and 34 deletions

View File

@ -3,8 +3,8 @@ import tensorflow as tf
import numpy as np
import warnings
import os
from keras.utils import load_img
import keras
from tensorflow.keras.utils import load_img
from tensorflow import keras
from sklearn.model_selection import train_test_split
from keras.preprocessing.image import ImageDataGenerator
from keras import Sequential
@ -91,7 +91,7 @@ class NeuralNetwork():
compile=True
)
def recognize(self, image_path):
image = keras.utils.load_img(image_path, target_size=(image_size, image_size))
image = load_img(image_path, target_size=(image_size, image_size))
image_array = keras.utils.img_to_array(image)
image_array = keras.backend.expand_dims(image_array, 0)

View File

@ -12,12 +12,12 @@ import pandas as pd
from classes import system, minesweeper, ai, decisionTrees
# ustalenie wielkości pojedyńczych kawałków mapy, oraz wielkości mapy
TILE_SIZE = 96
TILE_SIZE = 72
TILES_X = int(12)
TILES_Y = int(10)
# wł/wył muzyki
MUSIC = False
MUSIC = True
# ustalenie FPS
FPS = 60

View File

@ -1,31 +1,31 @@
[
{"current_level": 1, "leaf_id": "2ece3328-e767-11ec-802c-4ccc6afd6a08", "parents": "root", "rule": "else: return 'detonate'", "feature_idx": -1, "feature_name": "", "instances": 200, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 1, "leaf_id": "2ececefd-e767-11ec-804a-4ccc6afd6a08", "parents": "root", "rule": "if obj[4]<=80.67436609605278:", "feature_idx": 4, "feature_name": "Random_detonation_chance", "instances": 200, "metric": 0.9964625048848765, "return_statement": 0, "tree_id": 0},
{"current_level": 2, "leaf_id": "2edc6e09-e767-11ec-b67a-4ccc6afd6a08", "parents": "2ececefd-e767-11ec-804a-4ccc6afd6a08", "rule": "else: return 'detonate'", "feature_idx": -1, "feature_name": "", "instances": 161, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 2, "leaf_id": "2edd09e1-e767-11ec-b87c-4ccc6afd6a08", "parents": "2ececefd-e767-11ec-804a-4ccc6afd6a08", "rule": "if obj[2]<=0:", "feature_idx": 2, "feature_name": "Protection_from_defuse", "instances": 161, "metric": 0.9203523274205176, "return_statement": 0, "tree_id": 0},
{"current_level": 3, "leaf_id": "2ee9f96f-e767-11ec-b259-4ccc6afd6a08", "parents": "2edd09e1-e767-11ec-b87c-4ccc6afd6a08", "rule": "else: return 'detonate'", "feature_idx": -1, "feature_name": "", "instances": 135, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 3, "leaf_id": "2eea9544-e767-11ec-9dee-4ccc6afd6a08", "parents": "2edd09e1-e767-11ec-b87c-4ccc6afd6a08", "rule": "if obj[3]<=7:", "feature_idx": 3, "feature_name": "Meters_under_the_ground", "instances": 135, "metric": 0.7364977795505669, "return_statement": 0, "tree_id": 0},
{"current_level": 4, "leaf_id": "2ef42ba3-e767-11ec-99b1-4ccc6afd6a08", "parents": "2eea9544-e767-11ec-9dee-4ccc6afd6a08", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 116, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 4, "leaf_id": "2ef4c777-e767-11ec-8b3d-4ccc6afd6a08", "parents": "2eea9544-e767-11ec-9dee-4ccc6afd6a08", "rule": "if obj[1]<=1997.8794790831414:", "feature_idx": 1, "feature_name": "Year(older_more_difficult)", "instances": 116, "metric": 0.3936164041111624, "return_statement": 0, "tree_id": 0},
{"current_level": 5, "leaf_id": "2efb52ad-e767-11ec-a8d9-4ccc6afd6a08", "parents": "2ef4c777-e767-11ec-8b3d-4ccc6afd6a08", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 97, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 5, "leaf_id": "2efbef9f-e767-11ec-8aeb-4ccc6afd6a08", "parents": "2ef4c777-e767-11ec-8b3d-4ccc6afd6a08", "rule": "if obj[5]<=2:", "feature_idx": 5, "feature_name": "Detonation_power_in_m", "instances": 97, "metric": 0.445693177722561, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "2eff6e8b-e767-11ec-a0f6-4ccc6afd6a08", "parents": "2efbef9f-e767-11ec-8aeb-4ccc6afd6a08", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 65, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "2f003159-e767-11ec-bc64-4ccc6afd6a08", "parents": "2efbef9f-e767-11ec-8aeb-4ccc6afd6a08", "rule": "if obj[0]>3:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0.33352200393097664, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "2f00315a-e767-11ec-b1ab-4ccc6afd6a08", "parents": "2f003159-e767-11ec-bc64-4ccc6afd6a08", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 6, "leaf_id": "2f09062d-e767-11ec-bec0-4ccc6afd6a08", "parents": "2efbef9f-e767-11ec-8aeb-4ccc6afd6a08", "rule": "if obj[0]<=3:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0.33352200393097664, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "2f09062e-e767-11ec-b567-4ccc6afd6a08", "parents": "2f09062d-e767-11ec-bec0-4ccc6afd6a08", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 5, "leaf_id": "2f1a3992-e767-11ec-bcb8-4ccc6afd6a08", "parents": "2ef4c777-e767-11ec-8b3d-4ccc6afd6a08", "rule": "if obj[5]>2:", "feature_idx": 5, "feature_name": "Detonation_power_in_m", "instances": 97, "metric": 0.445693177722561, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "2f1df45d-e767-11ec-9b1a-4ccc6afd6a08", "parents": "2f1a3992-e767-11ec-bcb8-4ccc6afd6a08", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 32, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "2f1e9032-e767-11ec-8145-4ccc6afd6a08", "parents": "2f1a3992-e767-11ec-bcb8-4ccc6afd6a08", "rule": "if obj[0]<=7:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0.6252624052234231, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "2f1e9033-e767-11ec-ae84-4ccc6afd6a08", "parents": "2f1e9032-e767-11ec-8145-4ccc6afd6a08", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 6, "leaf_id": "2f273cd1-e767-11ec-9821-4ccc6afd6a08", "parents": "2f1a3992-e767-11ec-bcb8-4ccc6afd6a08", "rule": "if obj[0]>7:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0.6252624052234231, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "2f273cd2-e767-11ec-96af-4ccc6afd6a08", "parents": "2f273cd1-e767-11ec-9821-4ccc6afd6a08", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 4, "leaf_id": "2f4108be-e767-11ec-bfcb-4ccc6afd6a08", "parents": "2eea9544-e767-11ec-9dee-4ccc6afd6a08", "rule": "if obj[1]>1997.8794790831414:", "feature_idx": 1, "feature_name": "Year(older_more_difficult)", "instances": 116, "metric": 0.3936164041111624, "return_statement": 0, "tree_id": 0},
{"current_level": 5, "leaf_id": "2f4108bf-e767-11ec-aecd-4ccc6afd6a08", "parents": "2f4108be-e767-11ec-bfcb-4ccc6afd6a08", "rule": "return 'defuse'", "feature_idx": 1, "feature_name": "Year(older_more_difficult)", "instances": 116, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 3, "leaf_id": "2f52d6df-e767-11ec-ac3e-4ccc6afd6a08", "parents": "2edd09e1-e767-11ec-b87c-4ccc6afd6a08", "rule": "if obj[3]>7:", "feature_idx": 3, "feature_name": "Meters_under_the_ground", "instances": 135, "metric": 0.7364977795505669, "return_statement": 0, "tree_id": 0},
{"current_level": 4, "leaf_id": "2f52d6e0-e767-11ec-b6e4-4ccc6afd6a08", "parents": "2f52d6df-e767-11ec-ac3e-4ccc6afd6a08", "rule": "return 'detonate'", "feature_idx": 3, "feature_name": "Meters_under_the_ground", "instances": 135, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 2, "leaf_id": "2f6567d1-e767-11ec-ae72-4ccc6afd6a08", "parents": "2ececefd-e767-11ec-804a-4ccc6afd6a08", "rule": "if obj[2]>0:", "feature_idx": 2, "feature_name": "Protection_from_defuse", "instances": 161, "metric": 0.9203523274205176, "return_statement": 0, "tree_id": 0},
{"current_level": 3, "leaf_id": "2f6567d2-e767-11ec-b1b8-4ccc6afd6a08", "parents": "2f6567d1-e767-11ec-ae72-4ccc6afd6a08", "rule": "return 'detonate'", "feature_idx": 2, "feature_name": "Protection_from_defuse", "instances": 161, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 1, "leaf_id": "2f793070-e767-11ec-9adb-4ccc6afd6a08", "parents": "root", "rule": "if obj[4]>80.67436609605278:", "feature_idx": 4, "feature_name": "Random_detonation_chance", "instances": 200, "metric": 0.9964625048848765, "return_statement": 0, "tree_id": 0},
{"current_level": 2, "leaf_id": "2f793071-e767-11ec-9798-4ccc6afd6a08", "parents": "2f793070-e767-11ec-9adb-4ccc6afd6a08", "rule": "return 'detonate'", "feature_idx": 4, "feature_name": "Random_detonation_chance", "instances": 200, "metric": 0, "return_statement": 1, "tree_id": 0}
{"current_level": 1, "leaf_id": "8bb67edf-e806-11ec-bcb7-989096c0661b", "parents": "root", "rule": "else: return 'detonate'", "feature_idx": -1, "feature_name": "", "instances": 200, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 1, "leaf_id": "8bb71afc-e806-11ec-9ced-989096c0661b", "parents": "root", "rule": "if obj[4]<=80.67436609605278:", "feature_idx": 4, "feature_name": "Random_detonation_chance", "instances": 200, "metric": 0.9964625048848765, "return_statement": 0, "tree_id": 0},
{"current_level": 2, "leaf_id": "8bc5e0ee-e806-11ec-8cc3-989096c0661b", "parents": "8bb71afc-e806-11ec-9ced-989096c0661b", "rule": "else: return 'detonate'", "feature_idx": -1, "feature_name": "", "instances": 161, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 2, "leaf_id": "8bc655e8-e806-11ec-8da6-989096c0661b", "parents": "8bb71afc-e806-11ec-9ced-989096c0661b", "rule": "if obj[2]<=0:", "feature_idx": 2, "feature_name": "Protection_from_defuse", "instances": 161, "metric": 0.9203523274205176, "return_statement": 0, "tree_id": 0},
{"current_level": 3, "leaf_id": "8bd45908-e806-11ec-86fc-989096c0661b", "parents": "8bc655e8-e806-11ec-8da6-989096c0661b", "rule": "else: return 'detonate'", "feature_idx": -1, "feature_name": "", "instances": 135, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 3, "leaf_id": "8bd4e176-e806-11ec-a35e-989096c0661b", "parents": "8bc655e8-e806-11ec-8da6-989096c0661b", "rule": "if obj[3]<=7:", "feature_idx": 3, "feature_name": "Meters_under_the_ground", "instances": 135, "metric": 0.7364977795505669, "return_statement": 0, "tree_id": 0},
{"current_level": 4, "leaf_id": "8bdeb447-e806-11ec-be9f-989096c0661b", "parents": "8bd4e176-e806-11ec-a35e-989096c0661b", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 116, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 4, "leaf_id": "8bdf3cbf-e806-11ec-af0d-989096c0661b", "parents": "8bd4e176-e806-11ec-a35e-989096c0661b", "rule": "if obj[1]<=1997.8794790831414:", "feature_idx": 1, "feature_name": "Year(older_more_difficult)", "instances": 116, "metric": 0.3936164041111624, "return_statement": 0, "tree_id": 0},
{"current_level": 5, "leaf_id": "8be63e5b-e806-11ec-991f-989096c0661b", "parents": "8bdf3cbf-e806-11ec-af0d-989096c0661b", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 97, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 5, "leaf_id": "8be6c6c6-e806-11ec-97ef-989096c0661b", "parents": "8bdf3cbf-e806-11ec-af0d-989096c0661b", "rule": "if obj[5]<=2:", "feature_idx": 5, "feature_name": "Detonation_power_in_m", "instances": 97, "metric": 0.445693177722561, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "8bea9583-e806-11ec-97aa-989096c0661b", "parents": "8be6c6c6-e806-11ec-97ef-989096c0661b", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 65, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "8beb3173-e806-11ec-9c8b-989096c0661b", "parents": "8be6c6c6-e806-11ec-97ef-989096c0661b", "rule": "if obj[0]>3:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0.33352200393097664, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "8beb3174-e806-11ec-abd3-989096c0661b", "parents": "8beb3173-e806-11ec-9c8b-989096c0661b", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 6, "leaf_id": "8bf5ee43-e806-11ec-8b7d-989096c0661b", "parents": "8be6c6c6-e806-11ec-97ef-989096c0661b", "rule": "if obj[0]<=3:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0.33352200393097664, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "8bf5ee44-e806-11ec-8ad3-989096c0661b", "parents": "8bf5ee43-e806-11ec-8b7d-989096c0661b", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 65, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 5, "leaf_id": "8c0af2e2-e806-11ec-adc7-989096c0661b", "parents": "8bdf3cbf-e806-11ec-af0d-989096c0661b", "rule": "if obj[5]>2:", "feature_idx": 5, "feature_name": "Detonation_power_in_m", "instances": 97, "metric": 0.445693177722561, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "8c0ed518-e806-11ec-9cd2-989096c0661b", "parents": "8c0af2e2-e806-11ec-adc7-989096c0661b", "rule": "else: return 'defuse'", "feature_idx": -1, "feature_name": "", "instances": 32, "metric": 0, "return_statement": 0, "tree_id": 0},
{"current_level": 6, "leaf_id": "8c0f5dc0-e806-11ec-9467-989096c0661b", "parents": "8c0af2e2-e806-11ec-adc7-989096c0661b", "rule": "if obj[0]<=7:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0.6252624052234231, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "8c0f5dc1-e806-11ec-82ed-989096c0661b", "parents": "8c0f5dc0-e806-11ec-9467-989096c0661b", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 6, "leaf_id": "8c19cc5c-e806-11ec-933f-989096c0661b", "parents": "8c0af2e2-e806-11ec-adc7-989096c0661b", "rule": "if obj[0]>7:", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0.6252624052234231, "return_statement": 0, "tree_id": 0},
{"current_level": 7, "leaf_id": "8c19dfdf-e806-11ec-943f-989096c0661b", "parents": "8c19cc5c-e806-11ec-933f-989096c0661b", "rule": "return 'defuse'", "feature_idx": 0, "feature_name": "Size(bigger_more_difficult)", "instances": 32, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 4, "leaf_id": "8c39a13d-e806-11ec-a917-989096c0661b", "parents": "8bd4e176-e806-11ec-a35e-989096c0661b", "rule": "if obj[1]>1997.8794790831414:", "feature_idx": 1, "feature_name": "Year(older_more_difficult)", "instances": 116, "metric": 0.3936164041111624, "return_statement": 0, "tree_id": 0},
{"current_level": 5, "leaf_id": "8c39a13e-e806-11ec-8247-989096c0661b", "parents": "8c39a13d-e806-11ec-a917-989096c0661b", "rule": "return 'defuse'", "feature_idx": 1, "feature_name": "Year(older_more_difficult)", "instances": 116, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 3, "leaf_id": "8c4ee056-e806-11ec-8c2d-989096c0661b", "parents": "8bc655e8-e806-11ec-8da6-989096c0661b", "rule": "if obj[3]>7:", "feature_idx": 3, "feature_name": "Meters_under_the_ground", "instances": 135, "metric": 0.7364977795505669, "return_statement": 0, "tree_id": 0},
{"current_level": 4, "leaf_id": "8c4ee057-e806-11ec-97e3-989096c0661b", "parents": "8c4ee056-e806-11ec-8c2d-989096c0661b", "rule": "return 'detonate'", "feature_idx": 3, "feature_name": "Meters_under_the_ground", "instances": 135, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 2, "leaf_id": "8c6432eb-e806-11ec-aae0-989096c0661b", "parents": "8bb71afc-e806-11ec-9ced-989096c0661b", "rule": "if obj[2]>0:", "feature_idx": 2, "feature_name": "Protection_from_defuse", "instances": 161, "metric": 0.9203523274205176, "return_statement": 0, "tree_id": 0},
{"current_level": 3, "leaf_id": "8c6432ec-e806-11ec-8b44-989096c0661b", "parents": "8c6432eb-e806-11ec-aae0-989096c0661b", "rule": "return 'detonate'", "feature_idx": 2, "feature_name": "Protection_from_defuse", "instances": 161, "metric": 0, "return_statement": 1, "tree_id": 0},
{"current_level": 1, "leaf_id": "8c795e81-e806-11ec-9ecc-989096c0661b", "parents": "root", "rule": "if obj[4]>80.67436609605278:", "feature_idx": 4, "feature_name": "Random_detonation_chance", "instances": 200, "metric": 0.9964625048848765, "return_statement": 0, "tree_id": 0},
{"current_level": 2, "leaf_id": "8c795e82-e806-11ec-8dc1-989096c0661b", "parents": "8c795e81-e806-11ec-9ecc-989096c0661b", "rule": "return 'detonate'", "feature_idx": 4, "feature_name": "Random_detonation_chance", "instances": 200, "metric": 0, "return_statement": 1, "tree_id": 0}
]