tsai
tsai copied to clipboard
time series classification question
For time series classification tasks, if there is an imbalance in the data among categories, such as three categories where one category greatly outnumbers the others, how should I handle it? For example, by modifying the loss function to assign different weights to different categories. How should I modify the following code?
model = TST(dls.vars, dls.c, dls.len, dropout=.3, fc_dropout=.8).to(device) learn = Learner(dls, model, loss_func=LabelSmoothingCrossEntropyFlat(),metrics=[accuracy], cbs=ShowGraphCallback2()) start = time.time() learn.fit_one_cycle(50, lr_max=1e-4) print('\nElapsed time:', time.time() - start) learn.plot_metrics()