21 Μαρτίου, 1970

Πρόβλεψη για EXTRA 5 με seq2seq προσεγγιση.

 

Θα προχωρήσουμε σε πρόβλεψη των επόμενων 5 αριθμών .

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt

from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, mean_absolute_error,
median_absolute_error
from sklearn.metrics import mean_absolute_percentage_error, r2_score

from tensorflow.keras.models import Sequential, Model
from tensorflow.keras.layers import LSTM, Dropout, Dense, Input, Attention
from tensorflow.keras.layers import AdditiveAttention, Concatenate, Reshape, Dot,
 Activation, Lambda

from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau

from colorama import Fore, Style
from typing import Tuple, List

seed_value = 1
tf.random.set_seed(seed_value)
np.random.seed(seed_value)

def create_dataset() -> np.ndarray:
return np.array([


[
0.04, 0.23, 0.25, 0.31, 0.35],
[
0.02, 0.25, 0.27, 0.29, 0.35],
[
0.12, 0.15, 0.23, 0.24, 0.35],
[
0.06, 0.11, 0.12, 0.29, 0.34],
[
0.04, 0.05, 0.09, 0.11, 0.13],
[
0.03, 0.1, 0.13, 0.16, 0.18],
[
0.02, 0.03, 0.05, 0.08, 0.24],
[
0.06, 0.14, 0.15, 0.29, 0.33],
[
0.11, 0.15, 0.16, 0.2, 0.25],
[
0.09, 0.17, 0.22, 0.23, 0.29],
[
0.01, 0.1, 0.11, 0.18, 0.23],
[
0.02, 0.05, 0.16, 0.21, 0.35],
[
0.11, 0.22, 0.27, 0.32, 0.34],
[
0.06, 0.07, 0.11, 0.2, 0.31],
[
0.07, 0.09, 0.15, 0.27, 0.35],
[
0.01, 0.03, 0.08, 0.12, 0.16],
[
0.01, 0.2, 0.33, 0.34, 0.35],
[
0.07, 0.12, 0.13, 0.21, 0.33],
[
0.2, 0.21, 0.26, 0.28, 0.29],
[
0.07, 0.14, 0.2, 0.3, 0.31],
[
0.04, 0.06, 0.1, 0.14, 0.27],
[
0.02, 0.03, 0.09, 0.27, 0.32],
[
0.05, 0.08, 0.13, 0.23, 0.29],
[
0.01, 0.03, 0.12, 0.18, 0.29],
[
0.1, 0.19, 0.3, 0.32, 0.34],
[
0.05, 0.12, 0.24, 0.27, 0.34],
[
0.09, 0.1, 0.11, 0.2, 0.21],
[
0.1, 0.16, 0.17, 0.3, 0.32],
[
0.17, 0.22, 0.23, 0.24, 0.35],
[
0.13, 0.15, 0.21, 0.3, 0.35],
[
0.03, 0.04, 0.17, 0.3, 0.31],
[
0.15, 0.18, 0.22, 0.24, 0.29],
[
0.01, 0.15, 0.2, 0.22, 0.32],
[
0.1, 0.18, 0.21, 0.23, 0.25],
[
0.05, 0.15, 0.16, 0.31, 0.33],
[
0.04, 0.07, 0.1, 0.22, 0.34],
[
0.06, 0.08, 0.19, 0.23, 0.32],
[
0.04, 0.16, 0.17, 0.25, 0.35],
[
0.01, 0.03, 0.09, 0.19, 0.33],
[
0.02, 0.06, 0.09, 0.2, 0.28],
[
0.02, 0.06, 0.13, 0.18, 0.23],
[
0.03, 0.09, 0.17, 0.2, 0.28],
[
0.04, 0.09, 0.14, 0.29, 0.33],
[
0.06, 0.11, 0.19, 0.29, 0.3],
[
0.13, 0.14, 0.32, 0.34, 0.35],
[
0.1, 0.11, 0.14, 0.18, 0.32],
[
0.04, 0.07, 0.21, 0.23, 0.31],
[
0.09, 0.15, 0.2, 0.27, 0.28],
[
0.03, 0.05, 0.13, 0.15, 0.3],
[
0.02, 0.1, 0.14, 0.15, 0.16],
[
0.01, 0.03, 0.06, 0.16, 0.21],
[
0.01, 0.04, 0.06, 0.12, 0.35],
[
0.06, 0.1, 0.25, 0.26, 0.34],
[
0.12, 0.2, 0.21, 0.27, 0.32],
[
0.02, 0.05, 0.09, 0.26, 0.31],
[
0.02, 0.03, 0.06, 0.23, 0.27],
[
0.04, 0.22, 0.26, 0.29, 0.35],
[
0.05, 0.11, 0.17, 0.23, 0.33],
[
0.03, 0.09, 0.19, 0.22, 0.34],
[
0.1, 0.11, 0.18, 0.22, 0.34],
[
0.11, 0.22, 0.27, 0.33, 0.34],
[
0.1, 0.15, 0.23, 0.24, 0.32],
[
0.02, 0.12, 0.18, 0.27, 0.29],
[
0.11, 0.16, 0.17, 0.22, 0.33],
[
0.01, 0.1, 0.12, 0.13, 0.21],
[
0.05, 0.06, 0.08, 0.2, 0.27],
[
0.07, 0.12, 0.18, 0.23, 0.27],
[
0.09, 0.23, 0.27, 0.31, 0.35],
[
0.11, 0.17, 0.2, 0.25, 0.29],
[
0.04, 0.08, 0.19, 0.26, 0.28],
[
0.1, 0.12, 0.16, 0.22, 0.28],
[
0.04, 0.11, 0.13, 0.28, 0.3],
[
0.06, 0.16, 0.25, 0.29, 0.34],
[
0.03, 0.14, 0.26, 0.31, 0.33],
[
0.06, 0.08, 0.16, 0.17, 0.23],
[
0.06, 0.12, 0.2, 0.23, 0.3],
[
0.06, 0.16, 0.19, 0.22, 0.33],
[
0.16, 0.18, 0.24, 0.28, 0.33],
[
0.02, 0.16, 0.19, 0.29, 0.3],
[
0.02, 0.15, 0.19, 0.23, 0.3],
[
0.04, 0.13, 0.19, 0.24, 0.3],
[
0.05, 0.08, 0.09, 0.12, 0.28],
[
0.03, 0.13, 0.17, 0.18, 0.21],
[
0.06, 0.14, 0.16, 0.18, 0.24],
[
0.1, 0.11, 0.13, 0.21, 0.33],
[
0.08, 0.16, 0.17, 0.23, 0.29],
[
0.01, 0.17, 0.2, 0.27, 0.29],
[
0.05, 0.16, 0.25, 0.27, 0.33],
[
0.1, 0.12, 0.26, 0.27, 0.35],
[
0.02, 0.08, 0.1, 0.14, 0.16],
[
0.11, 0.16, 0.22, 0.25, 0.29],
[
0.12, 0.17, 0.18, 0.31, 0.33],
[
0.07, 0.16, 0.18, 0.27, 0.32],
[
0.03, 0.17, 0.22, 0.25, 0.32],
[
0.07, 0.08, 0.13, 0.21, 0.32],
[
0.08, 0.15, 0.25, 0.28, 0.33],
[
0.02, 0.04, 0.13, 0.17, 0.33],
[
0.02, 0.06, 0.07, 0.16, 0.25],
[
0.05, 0.18, 0.27, 0.3, 0.33],
[
0.03, 0.15, 0.2, 0.21, 0.25],
[
0.03, 0.13, 0.21, 0.22, 0.25],
[
0.12, 0.13, 0.19, 0.31, 0.35],
[
0.17, 0.18, 0.24, 0.25, 0.35],
[
0.01, 0.05, 0.13, 0.26, 0.31],
[
0.03, 0.17, 0.21, 0.22, 0.33],
[
0.04, 0.13, 0.22, 0.25, 0.31],
[
0.09, 0.11, 0.27, 0.3, 0.35],
[
0.1, 0.15, 0.16, 0.28, 0.34],
[
0.07, 0.1, 0.18, 0.23, 0.31],
[
0.11, 0.16, 0.26, 0.33, 0.35],
[
0.07, 0.09, 0.12, 0.23, 0.29],
[
0.07, 0.18, 0.24, 0.28, 0.32],
[
0.1, 0.12, 0.18, 0.2, 0.35],
[
0.05, 0.07, 0.19, 0.23, 0.26],
[
0.07, 0.12, 0.28, 0.3, 0.35],
[
0.04, 0.06, 0.1, 0.21, 0.28],
[
0.02, 0.04, 0.08, 0.1, 0.16],
[
0.09, 0.1, 0.2, 0.23, 0.31],
[
0.03, 0.18, 0.27, 0.28, 0.34],
[
0.07, 0.08, 0.1, 0.29, 0.35],
[
0.2, 0.24, 0.25, 0.27, 0.28],
[
0.09, 0.1, 0.19, 0.26, 0.29],
[
0.05, 0.09, 0.12, 0.13, 0.31],
[
0.13, 0.19, 0.3, 0.32, 0.33],
[
0.07, 0.09, 0.31, 0.33, 0.34],
[
0.11, 0.12, 0.19, 0.22, 0.27],
[
0.15, 0.2, 0.26, 0.27, 0.3],
[
0.07, 0.12, 0.2, 0.23, 0.34],
[
0.04, 0.06, 0.12, 0.27, 0.28],
[
0.1, 0.17, 0.2, 0.22, 0.29],
[
0.03, 0.06, 0.08, 0.15, 0.27],
[
0.06, 0.1, 0.19, 0.21, 0.34],
[
0.07, 0.13, 0.23, 0.25, 0.34],
[
0.15, 0.16, 0.21, 0.26, 0.32],
[
0.08, 0.19, 0.21, 0.22, 0.35],
[
0.04, 0.1, 0.12, 0.17, 0.27],
[
0.06, 0.21, 0.22, 0.29, 0.33],
[
0.01, 0.05, 0.18, 0.33, 0.35],
[
0.08, 0.09, 0.16, 0.17, 0.23],
[
0.02, 0.05, 0.15, 0.19, 0.22],
[
0.01, 0.04, 0.07, 0.09, 0.32],
[
0.06, 0.14, 0.19, 0.2, 0.27],
[
0.04, 0.08, 0.18, 0.22, 0.35],
[
0.09, 0.11, 0.19, 0.24, 0.29],
[
0.01, 0.02, 0.03, 0.18, 0.35],
[
0.01, 0.04, 0.19, 0.23, 0.31],
[
0.06, 0.1, 0.14, 0.26, 0.31],
[
0.03, 0.05, 0.06, 0.23, 0.32],
[
0.04, 0.05, 0.06, 0.1, 0.28],
[
0.08, 0.09, 0.1, 0.13, 0.17],
[
0.07, 0.15, 0.23, 0.26, 0.34],
[
0.07, 0.12, 0.18, 0.23, 0.29],
[
0.04, 0.07, 0.27, 0.29, 0.31],
[
0.01, 0.06, 0.1, 0.17, 0.19],
[
0.04, 0.22, 0.25, 0.27, 0.28],
[
0.07, 0.18, 0.21, 0.24, 0.35],
[
0.02, 0.07, 0.16, 0.26, 0.29],
[
0.13, 0.17, 0.19, 0.29, 0.33],
[
0.01, 0.2, 0.21, 0.22, 0.31],
[
0.08, 0.12, 0.14, 0.18, 0.19],
[
0.04, 0.13, 0.31, 0.32, 0.34],
[
0.01, 0.04, 0.11, 0.2, 0.35],
[
0.01, 0.08, 0.11, 0.13, 0.19],
[
0.04, 0.08, 0.17, 0.18, 0.34],
[
0.06, 0.08, 0.16, 0.25, 0.34],
[
0.02, 0.05, 0.18, 0.23, 0.28],
[
0.06, 0.12, 0.14, 0.15, 0.34],
[
0.09, 0.1, 0.14, 0.32, 0.35],
[
0.21, 0.24, 0.25, 0.3, 0.32],
[
0.08, 0.16, 0.17, 0.22, 0.29],
[
0.11, 0.21, 0.24, 0.29, 0.3],
[
0.04, 0.08, 0.2, 0.22, 0.25],
[
0.09, 0.11, 0.24, 0.28, 0.31],
[
0.03, 0.11, 0.2, 0.24, 0.26],
[
0.1, 0.14, 0.19, 0.22, 0.25],
[
0.06, 0.12, 0.23, 0.26, 0.33],
[
0.07, 0.1, 0.15, 0.24, 0.29
],
[
0.08, 0.18, 0.19, 0.28, 0.34],
[
0.01, 0.06, 0.08, 0.12, 0.16],
[
0.05, 0.08, 0.1, 0.24, 0.33],
[
0.13, 0.19, 0.23, 0.24, 0.32],
[
0.05, 0.09, 0.1, 0.16, 0.32],
[
0.08, 0.15, 0.2, 0.21, 0.28],
[
0.06, 0.17, 0.21, 0.22, 0.28],
[
0.01, 0.05, 0.09, 0.13, 0.33],
[
0.08, 0.19, 0.21, 0.22, 0.33],
[
0.04, 0.13, 0.14, 0.18, 0.26],
[
0.02, 0.04, 0.08, 0.18, 0.22],
[
0.09, 0.19, 0.24, 0.32, 0.33],
[
0.01, 0.02, 0.13, 0.16, 0.23],
[
0.01, 0.13, 0.15, 0.19, 0.24],
[
0.06, 0.12, 0.18, 0.27, 0.33],
[
0.1, 0.11, 0.24, 0.32, 0.33],
[
0.06, 0.14, 0.24, 0.29, 0.3],
[
0.03, 0.05, 0.09, 0.22, 0.25],
[
0.11, 0.13, 0.14, 0.19, 0.29],
[
0.07, 0.09, 0.15, 0.26, 0.34],
[
0.03, 0.07, 0.24, 0.27, 0.28],
[
0.11, 0.17, 0.2, 0.26, 0.28],
[
0.03, 0.07, 0.08, 0.11, 0.14],
[
0.06, 0.08, 0.13, 0.32, 0.35],
[
0.01, 0.06, 0.16, 0.17, 0.25],
[
0.17, 0.2, 0.27, 0.3, 0.33],
[
0.08, 0.16, 0.23, 0.29, 0.3],
[
0.03, 0.06, 0.1, 0.13, 0.34],
[
0.12, 0.14, 0.17, 0.24, 0.29],
[
0.01, 0.05, 0.07, 0.3, 0.35],
[
0.02, 0.09, 0.13, 0.14, 0.16],
[
0.05, 0.15, 0.25, 0.27, 0.31],
[
0.03, 0.06, 0.08, 0.17, 0.25],
[
0.07, 0.08, 0.1, 0.31, 0.32],
[
0.07, 0.08, 0.15, 0.25, 0.31],
[
0.06, 0.18, 0.27, 0.32, 0.35],
[
0.03, 0.11, 0.15, 0.28, 0.31],
[
0.01, 0.05, 0.09, 0.24, 0.32],
[
0.09, 0.1, 0.19, 0.28, 0.32],
[
0.05, 0.12, 0.23, 0.27, 0.31],
[
0.02, 0.08, 0.15, 0.2, 0.24],
[
0.13, 0.14, 0.18, 0.31, 0.32],
[
0.07, 0.11, 0.31, 0.32, 0.35],
[
0.05, 0.1, 0.21, 0.26, 0.27],
[
0.04, 0.1, 0.21, 0.29, 0.31],
[
0.06, 0.09, 0.12, 0.28, 0.29],
[
0.02, 0.1, 0.2, 0.31, 0.32],
[
0.12, 0.13, 0.18, 0.31, 0.32],
[
0.02, 0.03, 0.07, 0.15, 0.33],
[
0.08, 0.2, 0.27, 0.3, 0.33],
[
0.07, 0.18, 0.2, 0.22, 0.23],
[
0.02, 0.06, 0.26, 0.27, 0.34],
[
0.21, 0.25, 0.27, 0.33, 0.35],
[
0.14, 0.17, 0.2, 0.22, 0.29],
[
0.06, 0.26, 0.3, 0.32, 0.34],
[
0.01, 0.07, 0.18, 0.22, 0.29],
[
0.09, 0.12, 0.18, 0.21, 0.22],
[
0.13, 0.2, 0.25, 0.27, 0.35],
[
0.03, 0.08, 0.19, 0.3, 0.34],
[
0.25, 0.28, 0.29, 0.34, 0.35],
[
0.09, 0.15, 0.16, 0.34, 0.35],
[
0.13, 0.15, 0.2, 0.21, 0.26],
[
0.15, 0.21, 0.22, 0.3, 0.34],
[
0.01, 0.03, 0.12, 0.3, 0.34],
[
0.02, 0.04, 0.07, 0.09, 0.25],
[
0.04, 0.08, 0.17, 0.2, 0.32],
[
0.03, 0.12, 0.17, 0.27, 0.35],
[
0.07, 0.18, 0.2, 0.25, 0.34],
[
0.23, 0.29, 0.31, 0.33, 0.34],
[
0.03, 0.13, 0.16, 0.21, 0.31],
[
0.06, 0.13, 0.22, 0.25, 0.35],
[
0.01, 0.12, 0.14, 0.16, 0.19],
[
0.02, 0.1, 0.11, 0.14, 0.35],
[
0.06, 0.07, 0.1, 0.13, 0.34],
[
0.03, 0.13, 0.28, 0.29, 0.33],
[
0.25, 0.28, 0.3, 0.34, 0.35],
[
0.01, 0.04, 0.05, 0.08, 0.27],
[
0.05, 0.09, 0.19, 0.24, 0.3],
[
0.02, 0.11, 0.22, 0.33, 0.35],
[
0.01, 0.06, 0.2, 0.31, 0.32],
[
0.06, 0.09, 0.14, 0.16, 0.24],
[
0.01, 0.14, 0.16, 0.21, 0.33],
[
0.14, 0.16, 0.2, 0.24, 0.27],
[
0.13, 0.15, 0.17, 0.23, 0.34],
[
0.07, 0.11, 0.25, 0.28, 0.34],
[
0.06, 0.25, 0.28, 0.3, 0.34],
[
0.14, 0.2, 0.25, 0.29, 0.33],
[
0.06, 0.12, 0.21, 0.22, 0.23],
[
0.14, 0.16, 0.2, 0.26, 0.28],
[
0.04, 0.07, 0.11, 0.18, 0.22],
[
0.08, 0.09, 0.26, 0.29, 0.31],
[
0.05, 0.14, 0.19, 0.27, 0.31],
[
0.08, 0.12, 0.16, 0.18, 0.25],
[
0.03, 0.18, 0.19, 0.21, 0.24],
[
0.01, 0.02, 0.03, 0.05, 0.11],
[
0.14, 0.16, 0.22, 0.27, 0.3],
[
0.04, 0.13, 0.15, 0.2, 0.24],
[
0.06, 0.09, 0.12, 0.15, 0.17],
[
0.06, 0.1, 0.13, 0.15, 0.25],
[
0.17, 0.19, 0.25, 0.3, 0.33],
[
0.05, 0.17, 0.2, 0.28, 0.33],
[
0.06, 0.09, 0.1, 0.29, 0.33],
[
0.02, 0.11, 0.24, 0.26, 0.3],
[
0.04, 0.08, 0.17, 0.28, 0.29],
[
0.01, 0.04, 0.07, 0.16, 0.24],
[
0.03, 0.12, 0.15, 0.16, 0.32],
[
0.03, 0.12, 0.15, 0.18, 0.3],
[
0.03, 0.07, 0.16, 0.31, 0.34],
[
0.11, 0.12, 0.16, 0.21, 0.29],
[
0.01, 0.04, 0.06, 0.21, 0.28],
[
0.05, 0.15, 0.26, 0.29, 0.31],
[
0.02, 0.08, 0.24, 0.25, 0.28],
[
0.03, 0.06, 0.26, 0.28, 0.31],
[
0.02, 0.06, 0.12, 0.26, 0.34],
[
0.02, 0.07, 0.27, 0.29, 0.31],
[
0.09, 0.12, 0.19, 0.22, 0.35],
[
0.09, 0.2, 0.26, 0.3, 0.32],
[
0.05, 0.13, 0.15, 0.22, 0.23],
[
0.11, 0.13, 0.2, 0.29, 0.34],
[
0.07, 0.13, 0.18, 0.25, 0.31],
[
0.04, 0.07, 0.12, 0.32, 0.35],
[
0.07, 0.09, 0.14, 0.18, 0.21],
[
0.03, 0.11, 0.18, 0.2, 0.35],
[
0.02, 0.03, 0.04, 0.09, 0.17],
[
0.01, 0.02, 0.04, 0.12, 0.19],
[
0.08, 0.12, 0.24, 0.3, 0.33],
[
0.11, 0.14, 0.17, 0.22, 0.33],
[
0.02, 0.14, 0.15, 0.26, 0.3],
[
0.04, 0.1, 0.16, 0.19, 0.34],
[
0.01, 0.06, 0.19, 0.24, 0.27],
[
0.01, 0.05, 0.18, 0.31, 0.32],
[
0.13, 0.14, 0.15, 0.17, 0.21],
[
0.04, 0.07, 0.1, 0.26, 0.33],
[
0.02, 0.04, 0.05, 0.1, 0.35],
[
0.03, 0.05, 0.07, 0.11, 0.25],
[
0.03, 0.2, 0.24, 0.29, 0.33],
[
0.09, 0.15, 0.18, 0.29, 0.33],
[
0.05, 0.07, 0.16, 0.19, 0.21],
[
0.01, 0.22, 0.28, 0.29, 0.35],
[
0.02, 0.04, 0.09, 0.13, 0.22],
[
0.07, 0.08, 0.1, 0.22, 0.28],
[
0.02, 0.06, 0.08, 0.13, 0.15],
[
0.04, 0.22, 0.25, 0.26, 0.34],
[
0.16, 0.24, 0.27, 0.29, 0.3],
[
0.1, 0.23, 0.28, 0.31, 0.32],
[
0.01, 0.16, 0.24, 0.32, 0.35],
[
0.01, 0.06, 0.09, 0.19, 0.31],
[
0.02, 0.04, 0.06, 0.22, 0.26],
[
0.01, 0.02, 0.05, 0.2, 0.33],
[
0.01, 0.07, 0.13, 0.14, 0.22],
[
0.12, 0.23, 0.24, 0.27, 0.33],
[
0.03, 0.07, 0.23, 0.26, 0.33],
[
0.05, 0.06, 0.07, 0.18, 0.19],
[
0.01, 0.02, 0.08, 0.22, 0.33],
[
0.01, 0.06, 0.11, 0.22, 0.25],
[
0.1, 0.13, 0.22, 0.27, 0.29],
[
0.04, 0.18, 0.23, 0.29, 0.32],
[
0.04, 0.15, 0.16, 0.19, 0.26],
[
0.04, 0.05, 0.2, 0.27, 0.35],
[
0.09, 0.15, 0.17, 0.23, 0.27],
[
0.02, 0.08, 0.09, 0.17, 0.19],
[
0.02, 0.05, 0.12, 0.24, 0.3],
[
0.01, 0.03, 0.23, 0.33, 0.34],
[
0.03, 0.09, 0.14, 0.18, 0.26],
[
0.01, 0.06, 0.18, 0.19, 0.21],
[
0.03, 0.07, 0.08, 0.22, 0.29],
[
0.02, 0.16, 0.17, 0.32, 0.34],
[
0.09, 0.1, 0.17, 0.22, 0.27],
[
0.13, 0.16, 0.27, 0.29, 0.35],
[
0.05, 0.06, 0.15, 0.24, 0.25],
[
0.04, 0.08, 0.15, 0.2, 0.21],
[
0.18, 0.27, 0.28, 0.31, 0.34],
[
0.01, 0.05, 0.16, 0.18, 0.28],
[
0.07, 0.13, 0.14, 0.21, 0.22],
[
0.02, 0.14, 0.18, 0.26, 0.29],
[
0.17, 0.19, 0.24, 0.26, 0.3],
[
0.01, 0.14, 0.21, 0.24, 0.35],
[
0.03, 0.07, 0.1, 0.26, 0.35],
[
0.02, 0.11, 0.18, 0.2, 0.34],
[
0.1, 0.23, 0.24, 0.26, 0.34],
[
0.03, 0.06, 0.1, 0.27, 0.3],
[
0.01, 0.07, 0.16, 0.2, 0.31],
[
0.04, 0.08, 0.22, 0.24, 0.29],
[
0.08, 0.09, 0.15, 0.19, 0.21],
[
0.01, 0.02, 0.1, 0.12, 0.19],
[
0.06, 0.07, 0.11, 0.26, 0.34],
[
0.13, 0.19, 0.2, 0.3, 0.33],
[
0.01, 0.06, 0.17, 0.18, 0.28],
[
0.08, 0.12, 0.13, 0.23, 0.31],
[
0.16, 0.17, 0.18, 0.28, 0.34],
[
0.05, 0.06, 0.17, 0.21, 0.3],
[
0.12, 0.16, 0.19, 0.28, 0.29],
[
0.02, 0.04, 0.07, 0.29, 0.35],
[
0.07, 0.11, 0.22, 0.24, 0.27],
[
0.11, 0.18, 0.25, 0.26, 0.35],
[
0.04, 0.13, 0.3, 0.31, 0.33],
[
0.02, 0.03, 0.12, 0.18, 0.29],
[
0.05, 0.11, 0.14, 0.2, 0.32],
[
0.01, 0.05, 0.17, 0.22, 0.28],
[
0.19, 0.22, 0.26, 0.3, 0.34],
[
0.06, 0.16, 0.22, 0.27, 0.33],
[
0.05, 0.11, 0.14, 0.27, 0.31],
[
0.13, 0.17, 0.21, 0.24, 0.31],
[
0.03, 0.09, 0.17, 0.21, 0.3],
[
0.02, 0.08, 0.17, 0.19, 0.24],
[
0.08, 0.1, 0.15, 0.2, 0.26],
[
0.1, 0.13, 0.23, 0.32, 0.35],
[
0.04, 0.18, 0.21, 0.25, 0.31],
[
0.12, 0.13, 0.19, 0.23, 0.27],
[
0.09, 0.14, 0.16, 0.27, 0.34],
[
0.08, 0.1, 0.22, 0.25, 0.31
],

])


def create_sequences(data: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
input_data, output_data = [], []
for i in range(len(data) - 1):
input_data.append(data[i])
output_data.append(data[i + 1])
return np.array(input_data), np.array(output_data)

def split_data(input_data: np.ndarray, output_data: np.ndarray,
split_ratio: float = 0.8) -> Tuple[np.ndarray, np.ndarray, np.ndarray,
 np.ndarray]:
split_point = int(len(input_data) * split_ratio)
return input_data[:split_point], input_data[split_point:], output_data
[:split_point], output_data[split_point:]

def build_model(input_shape: Tuple[int, int], num_units: List[int]) -> Model:
encoder_inputs = Input(shape=input_shape)
encoder_lstm1 = LSTM(num_units[0], activation='tanh', return_sequences=True,
 return_state=True, unroll=True, unit_forget_bias=True)
encoder_outputs1, state_h1, state_c1 = encoder_lstm1(encoder_inputs)

encoder_lstm2 = LSTM(num_units[1], activation='tanh', return_sequences=True,
 return_state=True, unroll=True, unit_forget_bias=True)
encoder_outputs2, state_h2, state_c2 = encoder_lstm2(encoder_outputs1)
encoder_states = [state_h2, state_c2]

decoder_inputs = Input(shape=input_shape)
decoder_lstm1 = LSTM(num_units[0], activation='tanh', return_sequences=True,
 return_state=True, unroll=True, unit_forget_bias=True)
decoder_outputs1, _, _ = decoder_lstm1(decoder_inputs,
 initial_state=[state_h1, state_c1])

score = Dot(axes=[2, 2])([decoder_outputs1, encoder_outputs2])
attention_weights = Activation('tanh')(score)
context_vector = Dot(axes=[2, 1])([attention_weights, encoder_outputs2])
decoder_combined_context = Concatenate(axis=-1)([context_vector, decoder_outputs1])

decoder_lstm2 = LSTM(num_units[1], activation='tanh', return_sequences=True,
 return_state=True, unroll=True, unit_forget_bias=True)
decoder_outputs2, _, _ = decoder_lstm2(decoder_combined_context,
 initial_state=encoder_states)

decoder_dense = Dense(input_shape[1], activation='linear', use_bias=True)
decoder_outputs = decoder_dense(decoder_outputs2)

return Model([encoder_inputs, decoder_inputs], decoder_outputs)

def train_model(model: Model, train_X: np.ndarray, train_Y: np.ndarray, val_X:
np.ndarray, val_Y: np.ndarray, batch_size: int = 1, epochs: int = 50) ->
 tf.keras.callbacks.History:
early_stopping = EarlyStopping(monitor='val_loss', patience=15, verbose=2,
 mode='min', restore_best_weights=True)
reduce_lr = ReduceLROnPlateau(monitor='val_loss', patience=10, verbose=2,
mode='min', factor=0.001, min_lr=1e-7)
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001),
loss=tf.keras.losses.MeanSquaredError(),
metrics=[tf.keras.metrics.MeanSquaredError(),
tf.keras.metrics.
MeanAbsoluteError(),
tf.keras.metrics.
MeanAbsolutePercentageError()])
return model.fit([train_X, train_X], train_Y,
epochs=epochs,
batch_size=batch_size,
validation_data=([val_X, val_X], val_Y),
callbacks=[early_stopping, reduce_lr])

def make_predictions(model: Model, val_X: np.ndarray) -> np.ndarray:
return model.predict([val_X, val_X])

def display_results(predicted_next_line: np.ndarray, dataset: np.ndarray) ->
None:
predictions = np.round(predicted_next_line * 100).astype(int)
predicted_values = np.round(predicted_next_line * 100).astype(int)
actual_values = np.round(dataset[-1] * 100).astype(int)
predicted_set = set(predicted_values)
actual_set = set(actual_values)
common_values = predicted_set.intersection(actual_set)
common_values_sorted = sorted(common_values)

print(f"\n{Fore.GREEN}ΟΙ ΠΡΟΒΛΕΠΟΜΕΝΕΣ ΘΕΡΜΟΚΡΑΣΙΕΣ: {Style.RESET_ALL}
{', '.join(map(str, predictions))}")
temperatures = ', '.join(f"{temp * 100:.0f}" for temp in dataset[-1])
print(f"{Fore.MAGENTA}ΟΙ ΤΕΛΕΥΤΑΙΕΣ ΘΕΡΜΟΚΡΑΣΙΕΣ: {Style.RESET_ALL}
{Fore.RED}{temperatures}{Style.RESET_ALL}")
print(f"\n{Fore.CYAN}ΚΟΙΝΕΣ ΤΙΜΕΣ: {Style.RESET_ALL}{common_values_sorted}")

def main() -> None:
dataset = create_dataset()
input_data, output_data = create_sequences(dataset)
input_data = input_data.reshape(input_data.shape[0], 1, input_data.shape[1])
output_data = output_data.reshape(output_data.shape[0], 1, output_data.shape
[1])

train_X, val_X, train_Y, val_Y = split_data(input_data, output_data)

num_units = [128, 128]
model = build_model((1, dataset.shape[1]), num_units)
history = train_model(model, train_X, train_Y, val_X, val_Y)

next_line_input = dataset[-1].reshape(1, 1, dataset.shape[1])
predicted_next_line = make_predictions(model, next_line_input).reshape(-1)

display_results(predicted_next_line, dataset)
tf.keras.backend.
clear_session()

if __name__ == "__main__":
main
()

ΑΠΟΤΕΛΕΣΜΑΤΑ
ΟΙ ΠΡΟΒΛΕΠΟΜΕΝΟΙ ΑΡΙΘΜΟΙ: 7, 13, 18, 24, 30
Η ΤΕΛΕΥΤΑΙΑ ΚΛΗΡΩΣΗ: 8, 10, 22, 25, 31

ΚΟΙΝΕΣ ΤΙΜΕΣ: []