フィルターのクリア

SVM Model not working properly on test data

17 ビュー (過去 30 日間)
Adam Hasse
Adam Hasse 2018 年 1 月 8 日
コメント済み: G.N. Cobbold 2020 年 12 月 14 日
Hello all, I'm using fitcsvm to classify two sets of data, Class 1 and Class 2. When I train the model on a dataset and then check how it did using predict, it seems to be working perfectly. However, when I input a new dataset, it only ever classifies it in Class 2, even though I use the cost modifier to state that classifying Class 1 in Class 2 is three times worse than misclassifying Class 2 as a Class 1.
SVM Model:
SVMModel = fitcsvm(data, classLabel, 'KernelFunction', 'gaussian',...
'Standardize',true, 'ClassNames', {'Class 1','Class 2'},...
'Cost',[0 3; 1 0]);
Verification of Training set:
[svmLabel, score] = predict(SVMModel, data);
Test Set:
[newsvmLabel, score] = predict(SVMModel, testData);
I think I'm using it correctly, so any advice on what's going on would be much appreciated.
  1 件のコメント
the cyclist
the cyclist 2018 年 1 月 8 日
Can you upload the data, or a small sample that exhibits the problem? That way we can run your code and see for ourselves.

サインインしてコメントする。

回答 (3 件)

Bernhard Suhm
Bernhard Suhm 2018 年 2 月 23 日
You are applying the predict function correctly, so there must be something wrong with your testData, probably the type in one column doesn't match the training data. Without providing an example - as "the cyclist" request - impossible to help you further.

Roushanak Haji Hassani
Roushanak Haji Hassani 2018 年 10 月 1 日
did you solve the issue? I have a similar problem.
  1 件のコメント
Bernhard Suhm
Bernhard Suhm 2018 年 10 月 1 日
Without the data we are just guessing at what the problem may be. Actually you may need to look at your training data as well, maybe that's highly imbalanced and the cost function didn't work.

サインインしてコメントする。


Roushanak Haji Hassani
Roushanak Haji Hassani 2018 年 10 月 1 日
編集済み: Roushanak Haji Hassani 2018 年 10 月 1 日
I have attached the train data set and test here. The first column in the train dataset is the labels and the others are extracted features. I have applied Linear SVM classifier and I got 92.5 % accuracy on train data. But when I am applying on the test data the result is not good at all. I would appreciate if you let me know what is wrong with data.
  4 件のコメント
SALWA BEN YOUNES
SALWA BEN YOUNES 2020 年 10 月 7 日
Did you solve the issue? I have a similar problem
G.N. Cobbold
G.N. Cobbold 2020 年 12 月 14 日
Hi Salwa
Did you solve the issue? I have a similar problem

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSupport Vector Machine Classification についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by