decision tree integration + some fixes

This commit is contained in:
yanny 2023-06-20 03:32:12 +02:00
parent 795ed2dcc1
commit 4a9d18f710
4 changed files with 40 additions and 7 deletions

View File

@ -6,3 +6,5 @@ IPython
pydotplus
torch
tensorflow
Pillow
keras

View File

@ -13,9 +13,9 @@ model = load_model(model_path)
class_names = os.listdir(dataset_dir)
# Путь к файло проверки
dataset_dir = "rdy-dataset\\test\\rose\\377277099_544769262c_c.jpg"
dataset_dir = "dataset\iris\\71766650_e2d423bea7_c.jpg"
image_path = 'rdy-dataset\\test\\rose\\377277099_544769262c_c.jpg' # Replace with the path to your image
image_path = 'dataset\iris\\71766650_e2d423bea7_c.jpg' # Replace with the path to your image
image = cv2.imread(image_path)
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # Convert image to RGB format
image = cv2.resize(image, (64, 64)) # Resize image to match the input size of the model

View File

@ -60,6 +60,10 @@ class Field:
for y in range(len(self.Nodes[0])):
print(self.Nodes[x][y].Values, end=' ')
def set_type(self, pos, type):
X,Y = pos
self.Nodes[X][Y].Type = type
def Neighbors(field, pos):
x, y, dir = pos

View File

@ -1,5 +1,9 @@
import pandas as pd
import pygame
import random
from sklearn.preprocessing import LabelEncoder
#import Flower
import Beehive
import Frames
@ -240,9 +244,26 @@ print(len(check_path_A))
current_node = 0
step = 1
comeback = False
weather = random.choice(['Sunny', 'Rainy', 'Cloudy'])
temperature = random.choice(['High', 'Medium', 'Low'])
windspeed = random.choice(['Strong', 'Weak'])
pollenavailability = random.choice(['Low', 'Medium', 'High'])
beepopulation = random.choice(['Low','Moderate', 'High'])
timeofday = random.choice(['Morning', 'Afternoon', 'Evening'])
if len(check_path_A)>80:
flowerdistance = 'Far'
elif len(check_path_A)>50:
flowerdistance = 'Medium'
else:
flowerdistance = 'Close'
humidity = random.choice(['High','Normal'])
predictiondata = [[weather, temperature, windspeed, pollenavailability, beepopulation, timeofday, flowerdistance, humidity]]
feature_cols = ['Weather','Temperature','WindSpeed','PollenAvailability','BeePopulation','TimeOfDay','FlowerDistance','Humidity']
le = LabelEncoder()
le.fit(feature_cols)
encoded_data = pd.DataFrame(predictiondata, columns=feature_cols).apply(le.fit_transform)
prediction = clf.predict(encoded_data)
font = pygame.font.Font(None,32)
while True:
# check for events
for event in pygame.event.get():
@ -268,6 +289,7 @@ while True:
dis.blit(bee_image, (bee_x * tileSize, bee_y * tileSize))
pygame.display.update()
if (bee_x,bee_y) in flower_positions:
if field.get_type((bee_x,bee_y)) == FLOWER:
if chek_flower(pygame.image.load(field.get_image((bee_x,bee_y)))) not in ['western-poison-oak', 'water_lily']:
@ -276,7 +298,12 @@ while True:
field.set_type((bee_x,bee_y), SHORT)
else:
field.set_type((bee_x,bee_y), SHORT)
if prediction[0] == 0:
text = font.render('The bee refused to fly out for honey', True, (255, 0, 0))
text_rect = text.get_rect(center=(disX // 2, disY // 2))
dis.blit(text, text_rect)
pygame.display.update()
pygame.time.wait(10000000)
clock.tick(10)