time-series-foundation-models / lag-llama

Lag-Llama: Towards Foundation Models for Probabilistic Time Series Forecasting
Apache License 2.0
1.09k stars 121 forks source link

Forecasting custom dataset #7

Closed ArchanaNarayanan843 closed 3 months ago

ArchanaNarayanan843 commented 4 months ago

Can we use this model for forecasting on our custom data as of now?

afshinebtia commented 4 months ago

Can we use this model for forecasting on our custom data as of now?

Yes! You can follow the following example to convert your CSV file (here the CSV file has 2 columns; the first column is "time" which includes time stamps, and the second column is "value" which includes the values of the target variable):

context_length = 32
prediction_length = 48  
freq = "1H"  

# Read the CSV file
df = pd.read_csv('.\Test.csv', parse_dates=['time'], index_col='time')

df.index = df.index.to_period(freq)

time_series = df['value'].values

# Assuming a single time series for simplicity; for multiple series, adjust accordingly
start = df.index[0]

train_ds = ListDataset(
    [{'target': time_series[:-prediction_length], 'start': start}],
    freq=freq
)

test_ds = ListDataset(
    [{'target': time_series, 'start': start}],
    freq=freq
)
turkalpmd commented 4 months ago

for import ListDataset function;

from lag_llama.gluon.estimator import LagLlamaEstimator
turkalpmd commented 4 months ago

Example full code here

ArchanaNarayanan0210 commented 4 months ago

Thanks

ashok-arjun commented 4 months ago

Hi! Thank you for the issue, and thank you @turkalpmd for the efforts! We'll be adding a tutorial soon with options to load datasets in several formats (such as CSV). We appreciate your patience; thanks!

ashok-arjun commented 4 months ago

Hi @ArchanaNarayanan0210 @ArchanaNarayanan843 , we uploaded a new Colab demo with a tutorial to use a CSV dataset.

Please check it and let us know if your dataset fits into one of the categories explained there.

ashok-arjun commented 3 months ago

Closing this issue since it's stale. Feel free to open it if required.

Thanks, Arjun