decision tree integration fix + end text

This commit is contained in:
yanny 2023-06-20 03:54:52 +02:00
parent 4a9d18f710
commit 09456e6bc4

View File

@ -244,24 +244,24 @@ print(len(check_path_A))
current_node = 0 current_node = 0
step = 1 step = 1
comeback = False comeback = False
weather = random.choice(['Sunny', 'Rainy', 'Cloudy']) weather = random.choice([2, 1, 0])
temperature = random.choice(['High', 'Medium', 'Low']) temperature = random.choice([0,1,2])
windspeed = random.choice(['Strong', 'Weak']) windspeed = random.choice([1,0])
pollenavailability = random.choice(['Low', 'Medium', 'High']) pollenavailability = random.choice([0,1,2])
beepopulation = random.choice(['Low','Moderate', 'High']) beepopulation = random.choice([0,1,2])
timeofday = random.choice(['Morning', 'Afternoon', 'Evening']) timeofday = random.choice([0,1,2])
if len(check_path_A)>80: if len(check_path_A)>80:
flowerdistance = 'Far' flowerdistance = 1
elif len(check_path_A)>50: elif len(check_path_A)>50:
flowerdistance = 'Medium' flowerdistance = 2
else: else:
flowerdistance = 'Close' flowerdistance = 0
humidity = random.choice(['High','Normal']) humidity = random.choice([1,2])
predictiondata = [[weather, temperature, windspeed, pollenavailability, beepopulation, timeofday, flowerdistance, humidity]] predictiondata = [[weather, temperature, windspeed, pollenavailability, beepopulation, timeofday, flowerdistance, humidity]]
feature_cols = ['Weather','Temperature','WindSpeed','PollenAvailability','BeePopulation','TimeOfDay','FlowerDistance','Humidity'] feature_cols = ['Weather','Temperature','WindSpeed','PollenAvailability','BeePopulation','TimeOfDay','FlowerDistance','Humidity']
le = LabelEncoder() le = LabelEncoder()
le.fit(feature_cols) le.fit(feature_cols)
encoded_data = pd.DataFrame(predictiondata, columns=feature_cols).apply(le.fit_transform) encoded_data = pd.DataFrame(predictiondata, columns=feature_cols)
prediction = clf.predict(encoded_data) prediction = clf.predict(encoded_data)
font = pygame.font.Font(None,32) font = pygame.font.Font(None,32)
while True: while True:
@ -312,6 +312,10 @@ while True:
current_node = 0 current_node = 0
comeback = True comeback = True
elif current_node + 1 == len(path): elif current_node + 1 == len(path):
endtext = font.render('ДЕЛО СДЕЛАНО', True, (255,0,0))
endtext_rect = endtext.get_rect(center=(disX // 2, disY // 2))
dis.blit(endtext, endtext_rect)
pygame.display.update()
pygame.time.wait(1000000) pygame.time.wait(1000000)
if(step == -1 and current_node == 0): if(step == -1 and current_node == 0):
step *= -1 step *= -1