Clear Filters
Clear Filters

SVM program for spoofing detection

2 views (last 30 days)
University Student
University Student on 28 Mar 2021
Commented: Walter Roberson on 30 Mar 2021
Could someone put this in their MATLAB env and run, and let me know what I am doing wrong? Why am I not getting the plots from the data like I want?
  5 Comments
University Student
University Student on 29 Mar 2021
I am assuming that is where allData comes in again. So you need to include that in the code.
University Student
University Student on 29 Mar 2021
Or better yet, the output data from the detection file.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 29 Mar 2021
You are using
%one-class SVM according to Tax and Duin with C parameter 0.0033 and gamma 100 kernel RBF (Gaussian -t 2)
model = fitcsvm(labelTrain, trainSet(1:end,1:2), '-s 2 -t 2 -n 0.001 -g 100');
That last expression is not a valid formula for fitcsvm .
It looks to me as if it an character vector used to pass extra parameters to the kernel for the third-party SVMLIB's version of svmfit().
To select RBF, use
'KernelFunction', 'rbf'
You are doing one-class learning, so you should probably be using a 'Nu' parameter -- possibly 0.001 ?
The closest fitcsvm option to passing parameters to the kernel is 'HyperparameterOptimizationOptions' but it looks to me as if none of the ones available are of interest to you.
At the moment I do not see any equivalent to -g 100.
  3 Comments
University Student
University Student on 29 Mar 2021
These are all the files associated with the research. I am not understanding your comment. How come it is not a valid formula? MATLAB is making me use fitcsvm.
Walter Roberson
Walter Roberson on 30 Mar 2021
"'Y~x1+x2+x3'. In this form, Y represents the response variable, and x1, x2, and x3 represent the predictor variables."
So the only terms that can occur in the "formula" position are variable names from an input table, and the symbols ~ and + (and I think I saw - as well in some cases.) There is no provision for the "formula" to include numbers such as the "0.001" you have in your quoted string.
Furthermore, the use of formulas is only permitted when the input is a table, but you are instead using the X, Y input data form. When you pass in X, Y data then there are no table variable names anyhow.
Effectively when you use that quoted string, you are doing so in a way that MATLAB would expect a name/value pair of options, but the string you have passed is not a valid option name.
MATLAB is making me use fitcsvm.
No it is not. You can still go and install the third-party LIBSVM and use that.
Back around 2010, Mathworks did not offer any SVM itself, but an external organization built a software package named LIBSVM and made it available tor MATLAB use. The string you are using, '-s 2 -t 2 -n 0.001 -g 100' is options that would be passed to that external LIBSVM package.
Eventually, Mathworks added its own modified version of LIBSVM as an official part of the Statistics Toolbox. When it did that, it altered most of the function names, but it kept a couple of the names, even though the functions had different options than the LIBSVM functions did. This was confusing at times.
Then later still, Mathworks redesigned its SVM support into different functions with noticeably different interface than LIBSVM or the old SVM functions had; and after a few releases, it withdrew support for the modified LIBSVM it had been using.
fitsvm() is not the old svmtrain(); the datatypes it takes are different and the options are completely different and it produces different outputs. Some of the options to determine exactly how SVM was to work now have no equivalent. Mathworks' current fitcsvm() and associated routines are Support Vector, but they are not based on the software that supported options such as -g 100 .
If you need to replicate an old paper exactly, then you will need to install the third-party LIBSVM package and use it.

Sign in to comment.

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!