tsai icon indicating copy to clipboard operation
tsai copied to clipboard

How to use the data I've prepared for training

Open 642721838 opened this issue 1 year ago • 3 comments

In timeseriesAI, all the demos use predefined datasets, such as get_UCR_data(dsid, return_split=False). If you want to use your own prepared data, how can you call it before data reading and processing?

642721838 avatar Dec 12 '23 05:12 642721838

u can try this way:

import numpy as np
DATA_PATH = './npydata/'
# read dataset
X_train = np.load(DATA_PATH + 'X_train.npy')
y_train = np.load(DATA_PATH + 'y_train.npy')
X_test = np.load(DATA_PATH + 'X_test.npy')
y_test = np.load(DATA_PATH + 'y_test.npy')

# convert to dataloader
X, y, splits = combine_split_data([X_train, X_test], [y_train, y_test])
tfms  = [None, [Categorize()]]
dsets = TSDatasets(X, y, tfms=tfms, splits=splits, inplace=True)
dls = TSDataLoaders.from_dsets(dsets.train, dsets.valid, bs=64, batch_tfms=[TSStandardize()], num_workers=0)

where DATA_PATH is ur dataset with numpy form. Whats more, tsai library has specific format requirements for input data (such as X_train and X_test here). u can check this from their Tutorial: https://timeseriesai.github.io/tsai/tutorials.html

aaalvinnn avatar Dec 15 '23 05:12 aaalvinnn

TypeError Traceback (most recent call last) Cell In[81], line 13 10 X, y, splits = combine_split_data([X_train, X_test], [y_train, y_test]) 11 tfms = [None, [Categorize()]] ---> 13 dsets = TSDatasets(X, y, tfms=tfms, splits=splits, inplace=True) 14 dls = TSDataLoaders.from_dsets(dsets.train, dsets.valid, bs=64, batch_tfms=[TSStandardize()], num_workers=0)

TypeError: unhashable type: 'numpy.ndarray'

then I have this error when I used your sentence.could you do me a favor that what I should do?thanks a lot.

Albertccy avatar Dec 16 '23 08:12 Albertccy

Hey I am also facing this same issue. Were you able to resolve it? @Albertccy

aayushukla avatar Jan 15 '24 04:01 aayushukla