PythonとSVMを使用して分類タスクを実行しようとしています。
収集したデータから、各クラスの特徴ベクトルを抽出し、トレーニング セットを作成しました。特徴ベクトルには n 次元 (39 以上) があります。したがって、2 つのクラスについて、39 次元の特徴ベクトルのセットと、特徴ベクトルの各エントリに対応するクラス ラベルの 1 つの配列があるとします。現在、mlpy を使用して次のようなことを行っています。
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)))
#インスタンスの各エントリにラベルを割り当てる(+1/-1) (#featurevector 1 からのエントリには +1、featurevector2 には -1)
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
ここで何か間違いをしていますか?または、他のライブラリを使用する必要がありますか?助けてください。