ml-py svm converges but classifying wrongly
Question: I am trying to do some classification task with python and SVM.

From collected data I extracted the feature vectors for each class and created
a training set. The feature vectors have n-dimensions(39 or more). So, say for
2 classes I have a set of 39-d feature vectors and a single array of class
labels corresponding to each entry in the feature vector.Currently, I am using
mlpy and doing something like this:

    
    
    import numpy as np
    import mlpy 
    
    svm=mlpy.Svm('gaussian') #tried a linear kernel too but not having the convergence
    instance= np.vstack((featurevector1,featurevector1))
    label=np.hstack((np.ones((1,len(featurevector1),dtype=int),-1*np.ones((1,len(featurevector2),dtype=int))) 
    

#Assigning a label(+1/-1) for each entry in instance, (+1 for entries coming
from #featurevector 1 and -1 for featurevector2

    
    
    svm.compute(instance,label) #it converges and outputs 1
    svm.predict(testdata) #This one says all class label are 1 only whereas I ve testing data from both classes
    

Am I doing some mistake here? Or should I use some other library? Please help.


Answer: I don't use mlpy, but `np.ones((1,len(featurevector1))` should perhaps be just
`np.ones(len(featurevector1))` \--  
print `.shape` of each to see the difference.  
(If you have a link to public data anything like yours, could you post it
please ?)

