43601

ROC curve and libsvm

Given a ROC curve drawn with plotroc.m (see here):

<ol> <li><strong>Theoretical question:</strong> How to select the best threshold to be used?</li> <li><strong>Programming qeuestion:</strong> How to induce the libsvm classifier to work with the selected (best) threshold?</li> </ol>

Answer1:

ROC curve is plot generated by plotting fraction of true positive on y-axis versus fraction of false positive on x-axis. So, co-ordinates of any point (x,y) on ROC curve indicates FPR and TPR value at particular threshold. As shown in figure, we find the point (x,y) on ROC curve which corresponds to the minimum distance of that point from top-left corner (i.e given by(0,1)) of plot. The threshold value corresponding to that point is the required threshold. Sorry, I am not permitted to put any image, so couldn't explain with figure. But, for more details about this click ROC related help

Secondly, In libsvm, svmpredict function returns you probability of data sample belonging to a particular class. So, if that probability(for positive class) is greater than threshold (obtained from ROC plot) then we can classify the sample to positive class. These few lines might be usefull to you:

[pred_labels,~,p] = svmpredict(target_labels,feature_test,svmStruct,'-b 1');

% where, svmStruct is structure returned by svmtrain function.

op = p(:,svmStruct.Label==1); % This gives probability for positive % class (i.e whose label is 1 )

Now if this variable 'op' is greater than threshold then we can classify the corresponding test sample to positive class. This can be done as

op_labels = op>th; % where 'th' is threshold obtained from ROC

Recommend

  • Android viewpager glass background
  • Can I limit users to a specific range and zoom level on Google Maps?
  • Android Google maps co-ordinates
  • How to bind a canvas to a list of rectangles
  • Polyarea returns false value
  • Feeding gstreamer fdsrc via STDIN only produces fraction of expected result
  • Is there such a thing as static jar linking in java?
  • MVC4 ActionLink syntax for use with hidden text box values
  • What is the exact way of using regex_iterator in C++?
  • Geometry shader doesn't do anything when fed GL_POINTS
  • Parse returned C# list in AJAX success function
  • Avoiding try/catch hell in my web pages
  • How to increase the python speed over loops?
  • how to calculate distance between two points in google maps?
  • Keep same scale in different graphs ggplot2
  • JFreechart X and Y axis scaling
  • SQL Server 2008 R2 - Islands and Gaps [closed]
  • MATLAB - Classification output
  • SQL Server: +(unary) operator on non-numeric Strings
  • Jooq casting String to BigDecimal
  • Stitching 2 images (OpenCV)
  • Efficient & Pythonic way of finding all possible sublists of a list in given range and the minim
  • Is it possible to define rest argument in OCaml?
  • RxJava debounce by arbitrary value
  • Breaking out column by groups in Pandas
  • one Local Olampyad Questions on Informatic in 2011
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Android screen density dpi vs ppi
  • How would I use PHP exceptions to define a redirect?
  • How to extract text from Word files using C#?
  • Buffer size for converting unsigned long to string
  • How to stop GridView from loading again when I press back button?
  • need help with bizarre java.net.HttpURLConnection behavior
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?