How to use loss() function in SVM trained model

I have 40*5 matrix 'tsetALLstd.CSV', file 1 to 4 columns represent as a predictor and 5th column represents response variables. I have attached file in here, I used machine learning toolbox for train SVM model using that 'tsetALLstd.CSV' file and I export it to my Matlab workspace.I need to calculate classification error in SVM how should I do it?

Answers (1)

Stephan
Stephan on 5 May 2018
Edited: Stephan on 5 May 2018
Hi
here you find an example with step by step how to for your problem:
Best regards
Stephan

5 Comments

thank you I followed that but I got an error.
L = loss(SVMModel,TBL,ResponseVarName)
SVMModel = I put my trained SVM model
TBL = I put 40*5 matrix 'tsetALLstd.CSV'
ResponseVarName = what should I put ResponceVarName?
In your case the name of the 5th column
how should I name 5th column?
I try to below ways I got an error
Please send your .mat file containing O and trained model. Also please send your code you have tried.
Best regards
Stephan
Hi,
try with attached file...-
Load this file into Workspace and then type:
>> SVMModel = fitcecoc(tsetALLstd, 'VarName5')
SVMModel =
ClassificationECOC
PredictorNames: {'VarName1' 'VarName2' 'VarName3' 'VarName4'}
ResponseName: 'VarName5'
CategoricalPredictors: []
ClassNames: [0.0 1.0 2.0 3.0]
ScoreTransform: 'none'
BinaryLearners: {6×1 cell}
CodingName: 'onevsone'
Properties, Methods
>> CV = crossval(SVMModel)
CV =
classreg.learning.partition.ClassificationPartitionedECOC
CrossValidatedModel: 'ECOC'
PredictorNames: {'VarName1' 'VarName2' 'VarName3' 'VarName4'}
ResponseName: 'VarName5'
NumObservations: 40
KFold: 10
Partition: [1×1 cvpartition]
ClassNames: [0.0 1.0 2.0 3.0]
ScoreTransform: 'none'
Properties, Methods
>> Model_loss = kfoldLoss(CV)
Model_loss =
0
Best regards
Stephan

Sign in to comment.

Asked:

on 5 May 2018

Edited:

on 7 May 2018

Community Treasure Hunt

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

Start Hunting!