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?

Réponses (1)

Stephan
Stephan le 5 Mai 2018
Modifié(e) : Stephan le 5 Mai 2018

0 votes

Hi
here you find an example with step by step how to for your problem:
Best regards
Stephan

5 commentaires

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?
Stephan
Stephan le 5 Mai 2018
In your case the name of the 5th column
how should I name 5th column?
I try to below ways I got an error
Stephan
Stephan le 6 Mai 2018
Please send your .mat file containing O and trained model. Also please send your code you have tried.
Best regards
Stephan
Stephan
Stephan le 7 Mai 2018
Modifié(e) : Stephan le 7 Mai 2018
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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by