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
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