Search code examples
pythonopencvmachine-learningsvmmnist

SVM classifier giving wrong predictions for MNIST images


I'm using SVM to predict the values in MNIST dataset. The accuracy of the model comes close to 91% but when I use it along with open cv to predict the value of an image, the result always shows 0. What is the issue here? I've added the image that I'm using for reference.
Link to the code
enter image description here


Solution

  • The output of the prediction is not one-hot encoded, so you shouldn't apply np.argmax at the end.
    So try this,

    print("The predicted value is : ",prediction[0])