timeseriesAI / tsai

Time series Timeseries Deep Learning Machine Learning Python Pytorch fastai | State-of-the-art Deep Learning library for Time Series and Sequences in Pytorch / fastai
https://timeseriesai.github.io/tsai/
Apache License 2.0
4.91k stars 622 forks source link

time series classification question #910

Open ChaohuanDeng123 opened 1 week ago

ChaohuanDeng123 commented 1 week ago

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()