dear Thomas,
Thank you for your valuable help!
I was able to create time series data using the timeseriesAI
(my data are time series of length 500, and 11 targets) :
df = pd.read_csv('D:\\Projects\\PQD_classification\\NILM_Classific\\TS_AVG.csv') db = (TimeSeriesList.from_df(df, '.', cols=df.columns.values[:500], feat=None) .split_by_rand_pct(valid_pct=0.2, seed=seed) .label_from_df(cols=['AVG_1','AVG_2','AVG_3','AVG_4','AVG_5','AVG_6','AVG_7','AVG_8','AVG_9','AVG_10','AVG_11'], label_cls=FloatList) .databunch(bs=bs, val_bs=bs * 2, num_workers=0, device=torch.device('cuda')) .scale(scale_type=scale_type, scale_by_channel=scale_by_channel, scale_by_sample=scale_by_sample,scale_range=scale_range) ) db
Still, once that’s done, I find two problems:
-First, has to do with the learning rate finder. The validation loss during the search is always
#nan
.
arch = InceptionTime #
arch_kwargs = dict() #
opt_func=Ranger
model = arch(db.features, db.c, **arch_kwargs).to(device) #db.c=11
learn = Learner(db, model, metrics= [mean_absolute_error, r2_score], opt_func=opt_func,loss_func= nn.MSELoss())
learn.lr_find()
learn.recorder.plot(suggestion=True)
(also the Loss is very high…I wonder if regression for this problem is doable!)
-Second, Once I try to train the model, I get : ValueError: Supported target types are: ('binary', 'multiclass'). Got 'continuous' instead.
This is the code i used for the training:
from sklearn.model_selection import StratifiedKFold
skf=StratifiedKFold(n_splits=2, random_state=1, shuffle=True)
acc_val=[]
acc2_val=[]
np.random.seed(42)import time
start_time = time.time()for train_index, val_index in skf.split(df.index, df[‘AVG_1’]):
src = (TimeSeriesList.from_df(df, base_dir, cols=df.columns.values[:500], feat=None)
.split_by_idxs(train_index,val_index)
.label_from_df(cols=[‘AVG_1’,‘AVG_2’,‘AVG_3’,‘AVG_4’,‘AVG_5’,‘AVG_6’,‘AVG_7’,‘AVG_8’,‘AVG_9’,‘AVG_10’,‘AVG_11’], label_cls=FloatList))
data_fold = (src.databunch(bs=bs, val_bs=bs * 2, num_workers=1 , device=torch.device(‘cuda’))
.scale(scale_type=scale_type, scale_by_channel=scale_by_channel,scale_by_sample=scale_by_sample,scale_range=scale_range))
model = arch(db.features, db.c, **arch_kwargs).to(device)
learn = Learner(data_fold, model, loss_func=nn.MSELoss(), metrics=[mean_absolute_error, r2_score], opt_func=opt_func, callback_fns=ShowGraph)
learn.fit_one_cycle(2, slice(lr2))
loss,acc,acc2 = learn.validate()
acc_val.append(acc.numpy())
acc2_val.append(acc2.numpy())print("— %s seconds —" % (time.time() - start_time))
Do you have any input on the problems? Thank you again for all!