Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8964455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:35:39+00:00 2026-06-15T16:35:39+00:00

I’m writing an application that uses an SVM to do classification on some images

  • 0

I’m writing an application that uses an SVM to do classification on some images (specifically these). My Matlab implementation works really well. Using a SIFT bag-of-words approach, I’m able to get near 100% accuracy with a linear kernel.

I need to implement this in C++ for speed/portability reasons, and so I’ve tried using both libsvm and dlib. I’ve tried multiple SVM types (c_svm, nu_svm, one_class) and multiple kernels (linear, polynomial, rbf). The best I’ve been able to achieve is around 50% accuracy – even on the same samples that I’ve trained on. I’ve confirmed that my feature generators are working, because when I export my c++-generated features to Matlab and train on those, I’m able to get near-perfect results again.

Is there something magical about Matlab’s SVM implementation? Are there any common pitfalls or areas that I might look into that would explain the behavior I’m seeing? I know this is a little vague, but part of the problem is that I don’t know where to go. Please let me know in the comments if there is other info I can provide that would be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:35:40+00:00Added an answer on June 15, 2026 at 4:35 pm

    There is nothing magical about the Matlab version of the libraries, other that it runs in Matlab which makes it harder to shoot yourself on the foot.

    A check list:

    1. Are you normalizing your data, making all values lie between 0 and 1
      (or between -1 and 1), either linearly or using the mean and the
      standard deviation?
    2. Are you parameter searching for a good value of C (or C and gamma in
      the case of an RBF kernel)? Doing cross validation or on a hold out set?
    3. Are you sure that your’re handling NaN, and all other floating point
      nastiness? Matlab is very good at hiding this from you, C++ not so
      much.
    4. Could it be that you’re loading your data incorrectly, reading a
      “%s” into a double or something that is adding noise to your input
      data?
    5. Could it be that libsvm/dlib expects the data in row major order and
      your’re sending it in in column major (or the other way around)? Again Matlab makes this almost impossible, C++ not so much.
    6. 32-64 bit nastiness one version of the library, executable compiled
      with the other?

    Some other things:

    1. Could it be that in Matlab you’re somehow leaking the class (y) into
      the preprocessing? no one does this on purpose, but I’ve seen it happen.
      If you make almost any f(y) a feature, you’ll get almost 100%
      everytime.
    2. Sometimes it helps to verify that everything is numerically
      identical by printing to file before training both in C++ and
      Matlab.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.