Exemplo n.º 1
0
# Correction of time zone (LOTOS-EUROS time zone is UTC-0, Colombia is UTC-5)
UTC = 5

days_forecast = 1
dataM = DataManager(path="data/", filter_items=["pm25", "temperature", "wind"])

n_input_steps = 24 * 7 * semana
n_output_steps = 24 * 3

stations = pd.read_csv('./data/Lista_estaciones.csv', delimiter=',')
stations_SIATA = np.array(stations['PM25'].values).astype('str')
stations_Meteo = np.array(stations['Meteo'].values).astype('str')

mls = CnnMeteo(n_input_steps,
               n_features,
               n_output_steps,
               drop=True,
               n_LSTM_hidden_layers=n_LSTM_hidden_layers,
               n_cells=n_cells)
csv_writer_1 = CsvWriter()
csv_writer_2 = CsvWriter()
csv_writer_3 = CsvWriter()

for j in range(days_forecast):
    for station in range(len(stations_SIATA)):

        print(stations_SIATA[station])
        station_pm25 = dataM.get_pm25(stations_SIATA[station])
        station_t = dataM.get_temperature(stations_Meteo[station])
        station_w = dataM.get_wind(stations_Meteo[station])
        number_samples = min(len(station_t.Value.values),
                             len(station_pm25.CONCENTRATION.values))
Exemplo n.º 2
0
data_pm25 = np.copy(station82_pm25.CONCENTRATION.values)
data_t = np.copy(station82_t.Value.values)
data_w = np.copy(station82_w.Value.values)

ensembles_pm25 = dataM.generate_ensambles(data_pm25, 2.4, n_size)
ensembles_t = dataM.generate_ensambles(data_t, 0.5, n_size)
ensembles_w = dataM.generate_ensambles(data_w, 0.05, n_size)

file_name = "m_Weeks_" + str(semana) + "_hidden_" + str(
    n_LSTM_hidden_layers) + "_cells_" + str(
        n_cells) + "_" + mls_label[param] + ".h5"
titulo = mls_label[param] + str(semana) + "_hidden_" + str(
    n_LSTM_hidden_layers) + "_cells_" + str(n_cells)
mls = CnnMeteo(n_input_steps,
               n_features,
               n_output_steps,
               drop=True,
               n_LSTM_hidden_layers=n_LSTM_hidden_layers,
               n_cells=n_cells)
mls[param].load(file_name)

n_output_steps = 24 * 3
pre_processor = Combiner()
y_real_ensemble = []
yhat_ensemble = []
x_prev_ensemble = []
for i in range(n_size):
    X, y = pre_processor.combine(n_input_steps, n_output_steps, ensembles_t[:,
                                                                            i],
                                 ensembles_w[:, i], ensembles_pm25[:, i],
                                 station82_t.Date.dt.dayofweek.values,
                                 station82_t.Date.dt.hour.values,
Exemplo n.º 3
0
#Value to graph a moving average of observations. Just for graphical purposes
window_moving_average = 5

days_forecast = 1
dataM = DataManager(path="data/", filter_items=["pm25", "temperature", "wind"])

n_input_steps = 24 * 7 * semana
n_output_steps = 24 * 3

stations = pd.read_csv('./data/Lista_estaciones.csv', delimiter=',')
stations_SIATA = np.array(stations['PM25'].values).astype('str')
stations_Meteo = np.array(stations['Meteo'].values).astype('str')

mls = CnnMeteo(n_input_steps,
               n_features,
               n_output_steps,
               drop=True,
               n_LSTM_hidden_layers=n_LSTM_hidden_layers,
               n_cells=n_cells)
RMSE_LSTM_ML_2 = {}
for station in range(len(stations_SIATA)):
    #for station in range(1):
    print(stations_SIATA[station])
    station_pm25 = dataM.get_pm25(stations_SIATA[station])
    station_t = dataM.get_temperature(stations_Meteo[station])
    station_w = dataM.get_wind(stations_Meteo[station])
    number_samples = min(len(station_t.Value.values),
                         len(station_pm25.CONCENTRATION.values))
    station_pm25 = station_pm25[0:number_samples]
    station_t = station_t[0:number_samples]
    station_w = station_w[0:number_samples]
    pre_processor = Combiner()
Exemplo n.º 4
0
                             station82_t.Value.values,
                             station82_w.Value.values,
                             station82_pm25.CONCENTRATION.values,
                             station82_pm25.CONCENTRATION.values)

dates = (station82_pm25.Date.values)
dates = np.transpose(dates)

datesx, datesy = pre_processor.create_dataset(dates,
                                              look_back=n_input_steps,
                                              step_forecast=n_output_steps)
n_train = 9500
n_features = X.shape[2]

mls = [
    CnnMeteo(n_input_steps, n_features, n_output_steps, drop=True),
    CnvLstmMeteo(n_input_steps,
                 n_features,
                 n_output_steps,
                 reg=False,
                 drop=False),
    CnvLstmMeteo(n_input_steps,
                 n_features,
                 n_output_steps,
                 reg=True,
                 drop=True),
]

mls_label = ['CnnMeteo_d', 'CnvLstmMeteo', 'CnvLstmMeteo_r_d']

days_forecast = 1
Exemplo n.º 5
0
# pre-process data
n_input_steps = 24 * 7 * 2
n_output_steps = 24 * 3
pre_processor = Combiner()
X, y = pre_processor.combine(n_input_steps, n_output_steps, station82_t.Value.values, station82_w.Value.values,
                             station82_pm25.CONCENTRATION.values,station82_t.Date.dt.dayofweek.values,station82_t.Date.dt.hour.values , station82_pm25.CONCENTRATION.values)


print(X.shape)
print(y.shape)
# Create Model
n_train = 9500
n_features = X.shape[2]

mls = [CnnMeteo(n_input_steps, n_features, n_output_steps, reg=True),
       CnnMeteo(n_input_steps, n_features, n_output_steps, drop=True),
       CnnMeteo(n_input_steps, n_features, n_output_steps, reg=True, drop=True),
       LstmVanillaMeteo(n_input_steps, n_features, n_output_steps, reg=True),
       LstmVanillaMeteo(n_input_steps, n_features, n_output_steps, drop=True),
       LstmVanillaMeteo(n_input_steps, n_features, n_output_steps, reg=True, drop=True),
       LstmStackedMeteo(n_input_steps, n_features, n_output_steps, reg=True),
       LstmStackedMeteo(n_input_steps, n_features, n_output_steps, drop=True),
       LstmStackedMeteo(n_input_steps, n_features, n_output_steps, reg=True, drop=True),
       LstmBidireccionalMeteo(n_input_steps, n_features, n_output_steps, reg=True),
       LstmBidireccionalMeteo(n_input_steps, n_features, n_output_steps, drop=True),
       LstmBidireccionalMeteo(n_input_steps, n_features, n_output_steps, reg=True, drop=True),
       CnvLstmMeteo(n_input_steps, n_features, n_output_steps, reg=False, drop=False),
       CnvLstmMeteo(n_input_steps, n_features, n_output_steps, reg=True, drop=False),
       CnvLstmMeteo(n_input_steps, n_features, n_output_steps, reg=False, drop=True),
       CnvLstmMeteo(n_input_steps, n_features, n_output_steps, reg=True, drop=True),