Method for sequence to label Support Vector Machine (SVM) classification

조회 수: 4(최근 30일)
Alex McGovern
Alex McGovern 2021년 7월 28일
답변: Shivam Singh 2021년 8월 11일
I am a beginner in machine learning, trying to develop a model to predict the presenting complaint of a patient in the hospital depending on their Heart Rate, Respiratory Rate and Blood Oxygen saturation. I have three classes, 'O', 'M', 'W', each of which has readings for the heart rate (hr), resp rate (rr) and blood oxygen (o2) for the duration of their stay. The length of the sequences are different from subject to subject, and I currently have them organized into a cell array, which each cell containing the 3 vital sign vectors.
Originally I had tried to implement a LSTM with the following layers and options:
miniBatchSize = 13; %number of observations used per iteration
inputSize = 3; %number of features (rr,hr,o2)
numHiddenUnits = 100; %hidden units in lstm layers
numClasses = 3; %number of classification options
layers = [ ...
sequenceInputLayer(inputSize)
bilstmLayer(numHiddenUnits,'OutputMode','last')
dropoutLayer(0.3)
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer]
maxEpochs = 100;
options = trainingOptions('adam', ...
'ExecutionEnvironment','gpu', ...
'GradientThreshold',1, ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',0, ...
'Plots','training-progress', ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropPeriod',3, ...
'LearnRateDropFactor',0.5, ...
'InitialLearnRate',0.001);
net = trainNetwork(XTrain,YTrain',layers,options);
Which was based off of https://www.mathworks.com/help/deeplearning/ug/classify-sequence-data-using-lstm-networks.html. This did not perfrom well, and the accuracy and loss both oscillate during training:
It also tended to 'overfit' data and assume all the compliants were of class "O" because that class makes up aproximatley 75% of the training and test sets.
I asked a colleague who is more familar with machine learning than myself, and they suggested using a SVM to classify the sequences. My problem is I havent been able to find a way to create a multi-class sequence to label svm classifier on matlab. All the examples I find only use select features, and most focus on binary classifiers.
My question is does anyone know how to create a multi-class sequence to label svm classifier on matlab, or have any links to resources or examples where somethig similar has been done. Also, if that is not possible or not the best course of action, then does anyone have any ideas why my LSTM network has problems, and some fixes I could try or links/resources for that. Much appreciated.

답변(1개)

Shivam Singh
Shivam Singh 2021년 8월 11일
SVM for multiclass classification can be done using the fitcecoc function. For detailed implementation of the above function, you can refer to the following MATLAB Answer:
I think that the reason for overfitting may be due to less number of features per class and unbalanced dataset. Also, for unbalanced dataset problem, instead of cross entropy loss function, you can explore weighted cross entropy loss or focal loss. For more information, you can refer to the documentation of focalLossLayer.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by