octoenergy / timeserio

Better `keras` models for time series and beyond
MIT License
61 stars 16 forks source link

Is there a generator for multimodel.predict_generator()? #16

Closed MRYingLEE closed 4 years ago

MRYingLEE commented 4 years ago

I tried to modify the example of https://github.com/octoenergy/timeserio/blob/master/docs/source/examples/SolarGenerationTimeSeries_Part2.ipynb to use multimodel.predict_generator. I understand multimodel.predict() cannot work directly for the sequence reason. After the prediction, I will chart the predicted and the real value, just like what has been done in the part 1.

I use the following code

from timeserio.batches.chunked.pandas import SequenceForecastBatchGenerator

batchgen_test = SequenceForecastBatchGenerator(
    df=df_test, batch_size=2**15,
    sequence_length=6,
    sequence_columns=["generation", "Time_step"],
    last_step_columns=["Time_step"],
    forecast_steps_min=1,
    forecast_steps_max=2,
    batch_offset=False,
    id_column="country",
    batch_aggregator=1
)

%%time
test_hat= multimodel.predict_generator(batchgen_test, model="forecast", verbose=5)

To my surprise, test_hat has the shape of (1459, 1) while df_test has that of (8760, 8). I realized it was because of the generator.

I tried all kinds of generators in timeserio and I couldn't find one can be used in predict_generator() to generator prediction row by row.

Any suggestions?

Thank you in advance,

Ying

MRYingLEE commented 4 years ago

Just in case someone needs it. I implemented a rolling sequence generator at https://github.com/MRYingLEE/DeepTime-Deep-Learning-Framework-for-Time-Series-Forecasting/blob/master/MultiModel/2_Solar_Generation_with_rolling_sequence.ipynb .