def trainRBM_SVM(features, Cparam, nComponents):
[X, Y] = listOfFeatures2Matrix(features)
rbm = BernoulliRBM(n_components = nComponents, n_iter = 30, learning_rate = 0.2, verbose = True)
rbm.fit(X,Y)
newX = rbm.transform(X)
# colors = ["r","g","b"]
# for i in range(1,Y.shape[0],5):
# plt.plot(newX[i,:], colors[int(Y[i])])
# plt.show()
classifier = {}
classifier["rbm"] = rbm
svm = sklearn.svm.SVC(C = Cparam, kernel = 'linear', probability = True)
svm.fit(newX,Y)
classifier["svm"] = svm
return classifier
评论列表
文章目录