From 09456e6bc4f0a83575acc7d734c8a3ceac7fea17 Mon Sep 17 00:00:00 2001 From: yanny Date: Tue, 20 Jun 2023 03:54:52 +0200 Subject: [PATCH] decision tree integration fix + end text --- src/main.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main.py b/src/main.py index 470b3f78..4a9e7aef 100644 --- a/src/main.py +++ b/src/main.py @@ -244,24 +244,24 @@ 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']) +weather = random.choice([2, 1, 0]) +temperature = random.choice([0,1,2]) +windspeed = random.choice([1,0]) +pollenavailability = random.choice([0,1,2]) +beepopulation = random.choice([0,1,2]) +timeofday = random.choice([0,1,2]) if len(check_path_A)>80: - flowerdistance = 'Far' + flowerdistance = 1 elif len(check_path_A)>50: - flowerdistance = 'Medium' + flowerdistance = 2 else: - flowerdistance = 'Close' -humidity = random.choice(['High','Normal']) + flowerdistance = 0 +humidity = random.choice([1,2]) 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) +encoded_data = pd.DataFrame(predictiondata, columns=feature_cols) prediction = clf.predict(encoded_data) font = pygame.font.Font(None,32) while True: @@ -312,6 +312,10 @@ while True: current_node = 0 comeback = True 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) if(step == -1 and current_node == 0): step *= -1