Добавил ген.алгоритм
This commit is contained in:
parent
7c3020625c
commit
479392c652
29
graph_show.py
Normal file
29
graph_show.py
Normal file
@ -0,0 +1,29 @@
|
||||
from matplotlib.lines import Line2D
|
||||
|
||||
vertex = ((0, 1), (1, 1), (0.5, 0.8), (0.1, 0.5), (0.8, 0.2), (0.4, 0))
|
||||
|
||||
vx = [v[0] for v in vertex]
|
||||
vy = [v[1] for v in vertex]
|
||||
|
||||
def show_graph(ax, best):
|
||||
ax.add_line(Line2D((vertex[0][0], vertex[1][0]), (vertex[0][1], vertex[1][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[0][0], vertex[2][0]), (vertex[0][1], vertex[2][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[0][0], vertex[3][0]), (vertex[0][1], vertex[3][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[1][0], vertex[2][0]), (vertex[1][1], vertex[2][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[2][0], vertex[5][0]), (vertex[2][1], vertex[5][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[2][0], vertex[4][0]), (vertex[2][1], vertex[4][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[3][0], vertex[5][0]), (vertex[3][1], vertex[5][1]), color='#aaa'))
|
||||
ax.add_line(Line2D((vertex[4][0], vertex[5][0]), (vertex[4][1], vertex[5][1]), color='#aaa'))
|
||||
|
||||
startV = 0
|
||||
for i, v in enumerate(best):
|
||||
if i == 0:
|
||||
continue
|
||||
|
||||
prev = startV
|
||||
v = v[:v.index(i)+1]
|
||||
for j in v:
|
||||
ax.add_line(Line2D((vertex[prev][0], vertex[j][0]), (vertex[prev][1], vertex[j][1]), color='r'))
|
||||
prev = j
|
||||
|
||||
ax.plot(vx, vy, ' ob', markersize=15)
|
15
model.py
15
model.py
@ -11,6 +11,10 @@ model = tf.keras.models.load_model('best_model_lstm_negative.keras')
|
||||
with open('tokenizer_lstm_lstm_negative.pickle', 'rb') as handle:
|
||||
tokenizer = pickle.load(handle)
|
||||
|
||||
# Загрузка названий классов
|
||||
with open('class_names_lstm_negative.txt', 'r', encoding='utf-8') as file:
|
||||
class_names = [line.strip() for line in file.readlines()]
|
||||
|
||||
def preprocess_text(text: str):
|
||||
# Токенизация текста
|
||||
sequences = tokenizer.texts_to_sequences([text])
|
||||
@ -26,8 +30,9 @@ def predict_answer(question: str) -> str:
|
||||
# Предсказание
|
||||
prediction = model.predict(input_data)
|
||||
print("Предсказание:", prediction)
|
||||
# Преобразование предсказания в строку для сохранения
|
||||
prediction_str = np.array2string(prediction[0], separator=',')
|
||||
print("Строковое представление предсказания:", prediction_str)
|
||||
return prediction_str # Возвращаем строковое представление предсказания
|
||||
|
||||
# Определение индекса класса с наибольшей вероятностью
|
||||
predicted_index = np.argmax(prediction[0])
|
||||
# Получение имени класса
|
||||
predicted_class = class_names[predicted_index]
|
||||
print("Предсказанный класс:", predicted_class)
|
||||
return predicted_class # Возвращаем имя предсказанного класса
|
||||
|
240
molirabotai.json
Normal file
240
molirabotai.json
Normal file
@ -0,0 +1,240 @@
|
||||
{
|
||||
"from": "Барнаул, Михайловка, BAX",
|
||||
"to": "Анапа, Витязево, AAQ",
|
||||
"countBusiness": 2,
|
||||
"countEconomic": 2,
|
||||
"departureDate": "2024-06-14",
|
||||
"returnDate": "2024-09-04",
|
||||
"flights": [
|
||||
{
|
||||
"id": 61,
|
||||
"departurePoint": "Казань, Казань, KZN",
|
||||
"destinationPoint": "Санкт-Петербург, Пулково, LED",
|
||||
"destinationTime": "2024-08-20T13:07:00",
|
||||
"departureTime": "2024-08-20T10:24:00",
|
||||
"distance": 1220.6400474973418,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"departurePoint": "Иркутск, Иркутск, IKT",
|
||||
"destinationPoint": "Братск, Братск, BTK",
|
||||
"destinationTime": "2024-07-11T10:28:00",
|
||||
"departureTime": "2024-07-11T09:23:00",
|
||||
"distance": 487.9816774502034,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"departurePoint": "Краснодар, Пашковский, KRR",
|
||||
"destinationPoint": "Махачкала, Уйташ, MCX",
|
||||
"destinationTime": "2024-08-13T00:14:00",
|
||||
"departureTime": "2024-08-12T22:38:00",
|
||||
"distance": 722.9657315613899,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 64,
|
||||
"departurePoint": "Нарьян-Мар, Нарьян-Мар, NNM",
|
||||
"destinationPoint": "Ульяновск, Баратаевка, ULY",
|
||||
"destinationTime": "2024-08-26T13:27:00",
|
||||
"departureTime": "2024-08-26T09:06:00",
|
||||
"distance": 1507.5398828540344,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 65,
|
||||
"departurePoint": "Сургут, Сургут, SGC",
|
||||
"destinationPoint": "Оренбург, Оренбург, REN",
|
||||
"destinationTime": "2024-06-26T19:15:00",
|
||||
"departureTime": "2024-06-26T15:52:00",
|
||||
"distance": 1519.299200422927,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 66,
|
||||
"departurePoint": "Махачкала, Уйташ, MCX",
|
||||
"destinationPoint": "Норильск, Алыкель, NSK",
|
||||
"destinationTime": "2024-07-21T06:10:00",
|
||||
"departureTime": "2024-07-20T17:56:00",
|
||||
"distance": 3703.9000546114958,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 67,
|
||||
"departurePoint": "Барнаул, Михайловка, BAX",
|
||||
"destinationPoint": "Белгород, им. В.Г. Шухова, EGO",
|
||||
"destinationTime": "2024-06-14T10:24:00",
|
||||
"departureTime": "2024-06-14T07:14:00",
|
||||
"distance": 3228.5554208976832,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
},
|
||||
{
|
||||
"id": 68,
|
||||
"departurePoint": "Краснодар, Пашковский, KRR",
|
||||
"destinationPoint": "Норильск, Алыкель, NSK",
|
||||
"destinationTime": "2024-09-09T11:24:00",
|
||||
"departureTime": "2024-09-08T22:57:00",
|
||||
"distance": 3801.082681475355,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 69,
|
||||
"departurePoint": "Нижний Новгород, Стригино, GOJ",
|
||||
"destinationPoint": "Казань, Казань, KZN",
|
||||
"destinationTime": "2024-06-18T12:06:00",
|
||||
"departureTime": "2024-06-18T11:19:00",
|
||||
"distance": 349.6277459879821,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
},
|
||||
{
|
||||
"id": 70,
|
||||
"departurePoint": "Благовещенск, Игнатьево, BQS",
|
||||
"destinationPoint": "Набережные Челны, Бегишево, NBC",
|
||||
"destinationTime": "2024-07-22T18:59:00",
|
||||
"departureTime": "2024-07-22T13:44:00",
|
||||
"distance": 5063.878359107013,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 71,
|
||||
"departurePoint": "Иркутск, Иркутск, IKT",
|
||||
"destinationPoint": "Барнаул, Михайловка, BAX",
|
||||
"destinationTime": "2024-06-15T09:29:00",
|
||||
"departureTime": "2024-06-15T07:21:00",
|
||||
"distance": 1407.5882508285608,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"departurePoint": "Ноябрьск, Ноябрьск, NOJ",
|
||||
"destinationPoint": "Челябинск, Баландино, CEK",
|
||||
"destinationTime": "2024-09-16T06:17:00",
|
||||
"departureTime": "2024-09-16T03:42:00",
|
||||
"distance": 1160.5033298370313,
|
||||
"countEconomic": 65,
|
||||
"countBusiness": 10
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"departurePoint": "Москва, Внуково, VKO",
|
||||
"destinationPoint": "Ростов-на-Дону, Платов, ROV",
|
||||
"destinationTime": "2024-09-12T18:07:00",
|
||||
"departureTime": "2024-09-12T16:05:00",
|
||||
"distance": 918.091611352077,
|
||||
"countEconomic": 74,
|
||||
"countBusiness": 11
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"departurePoint": "Владивосток, Кневичи, VVO",
|
||||
"destinationPoint": "Барнаул, Михайловка, BAX",
|
||||
"destinationTime": "2024-08-15T16:18:00",
|
||||
"departureTime": "2024-08-15T11:01:00",
|
||||
"distance": 3730.5081332082163,
|
||||
"countEconomic": 79,
|
||||
"countBusiness": 12
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"departurePoint": "Петрозаводск, Бесовец, PES",
|
||||
"destinationPoint": "Сургут, Сургут, SGC",
|
||||
"destinationTime": "2024-09-01T11:50:00",
|
||||
"departureTime": "2024-09-01T05:13:00",
|
||||
"distance": 2077.379976088868,
|
||||
"countEconomic": 169,
|
||||
"countBusiness": 18
|
||||
},
|
||||
{
|
||||
"id": 53,
|
||||
"departurePoint": "Уфа, Уфа, UFA",
|
||||
"destinationPoint": "Москва, Домодедово, DME",
|
||||
"destinationTime": "2024-09-20T09:46:00",
|
||||
"departureTime": "2024-09-20T09:12:00",
|
||||
"distance": 1151.602690782937,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 54,
|
||||
"departurePoint": "Нижний Новгород, Стригино, GOJ",
|
||||
"destinationPoint": "Красноярск, Емельяново, KJA",
|
||||
"destinationTime": "2024-08-04T23:35:00",
|
||||
"departureTime": "2024-08-04T12:53:00",
|
||||
"distance": 3015.7580421346734,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 55,
|
||||
"departurePoint": "Краснодар, Пашковский, KRR",
|
||||
"destinationPoint": "Омск, Центральный, OMS",
|
||||
"destinationTime": "2024-07-28T19:22:00",
|
||||
"departureTime": "2024-07-28T10:27:00",
|
||||
"distance": 2659.8366524460557,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 56,
|
||||
"departurePoint": "Полярный, Полярный, PYJ",
|
||||
"destinationPoint": "Благовещенск, Игнатьево, BQS",
|
||||
"destinationTime": "2024-09-04T06:44:00",
|
||||
"departureTime": "2024-09-04T02:21:00",
|
||||
"distance": 1974.1571330162965,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
},
|
||||
{
|
||||
"id": 57,
|
||||
"departurePoint": "Братск, Братск, BTK",
|
||||
"destinationPoint": "Тюмень, Рощино, THX",
|
||||
"destinationTime": "2024-07-21T18:08:00",
|
||||
"departureTime": "2024-07-21T16:12:00",
|
||||
"distance": 2219.622819604269,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 58,
|
||||
"departurePoint": "Белгород, им. В.Г. Шухова, EGO",
|
||||
"destinationPoint": "Анапа, Витязево, AAQ",
|
||||
"destinationTime": "2024-08-15T13:44:00",
|
||||
"departureTime": "2024-08-15T12:20:00",
|
||||
"distance": 629.2506997536557,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
},
|
||||
{
|
||||
"id": 59,
|
||||
"departurePoint": "Белгород, им. В.Г. Шухова, EGO",
|
||||
"destinationPoint": "Казань, Казань, KZN",
|
||||
"destinationTime": "2024-08-24T22:45:00",
|
||||
"departureTime": "2024-08-24T20:30:00",
|
||||
"distance": 1009.1424941120106,
|
||||
"countEconomic": 265,
|
||||
"countBusiness": 36
|
||||
},
|
||||
{
|
||||
"id": 60,
|
||||
"departurePoint": "Москва, Внуково, VKO",
|
||||
"destinationPoint": "Нижний Новгород, Стригино, GOJ",
|
||||
"destinationTime": "2024-09-04T19:53:00",
|
||||
"departureTime": "2024-09-04T18:58:00",
|
||||
"distance": 413.0044473319829,
|
||||
"countEconomic": 120,
|
||||
"countBusiness": 20
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user