how adjust SVM classifier prediction threshold in matlab

7 次查看(过去 30 天)
base on a paper I should train a SVM and the paper said 'Given the learned SVM classifier we then adjust its prediction threshold so that it achieves high precision.' Can you help me how I should do that. the author of the paper don't answer the question and I really need that.

回答(1 个)

Jeffrey Girard
Jeffrey Girard 2015-7-17
编辑:Jeffrey Girard 2015-7-17
The output of the "predict" function of an SVM implementation will be a vector of size N, where N is the number of examples you are trying to get predictions for. The numbers in this vector correspond to each example's distance to the class-separating hyperplane. In order to dichotomize these values so that each is a binary corresponding to class membership, you need to use a prediction threshold. Any number greater than or equal to that threshold will be predicted to be part of the positive class and any number less than that threshold will be predicted to be part of the negative class. The definition of the SVM algorithm will ensure that a prediction threshold of 0 is the optimal threshold for the training data (i.e., it yields the highest classification accuracy). However, for generalizing to independent data sets, you may want to adjust the prediction threshold and see how your performance metric of choice (e.g., accuracy, precision, or recall) is affected. I suggest writing a simple function that accepts data and a prediction threshold and outputs a performance metric. You can then try different thresholds by looping over a range from the minimum to the maximum output value:
linspace(min(output),max(output),10)
  2 个评论
mary khaliji
mary khaliji 2015-7-18
thank you for your response. Can you say me how I can obtain precision and recall from svmtrain() or svmclassify() functions?
Sedo
Sedo 2022-4-25
You've probably gotten your answer by now but, in case anyone else needs the answer, you can use the predicted label you got from the predict function and your triane dsmv model to get a confusion matrix. This can be done by inputting the actual labels and the predicted labels (gotten from the output of the predict function and your trained classifier) into the confusion amtirx function. Then you can use that confusion matrix to get your precision and recall.

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by