本文整理匯總了Python中shogun.Classifier.LibSVM.set_linear_term方法的典型用法代碼示例。如果您正苦於以下問題:Python LibSVM.set_linear_term方法的具體用法?Python LibSVM.set_linear_term怎麽用?Python LibSVM.set_linear_term使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類shogun.Classifier.LibSVM
的用法示例。
在下文中一共展示了LibSVM.set_linear_term方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: assert
# 需要導入模塊: from shogun.Classifier import LibSVM [as 別名]
# 或者: from shogun.Classifier.LibSVM import set_linear_term [as 別名]
#print inner[i], tmp_out[i]
assert(abs(inner[i]-tmp_out[i])<= 0.001)
svm = SVMLight(1.0, wdk, lab)
svm.set_linear_term(p)
Math_init_random(1)
svm.train()
###############
#compare to LibSVM
svm2 = LibSVM(1.0, wdk, lab)
svm2.set_linear_term(p)
Math_init_random(1)
svm2.train()
svm3 = LibSVM(1.0, wdk, lab)
Math_init_random(1)
svm3.train()
print "SVMLight linear:", svm.get_objective()
print "LibSVM linear:", svm2.get_objective()
print "LibSVM:", svm3.get_objective()
print svm.get_objective(), svm2.get_objective()
assert(abs(svm.get_objective()-svm2.get_objective())<= 0.001)
示例2: xrange
# 需要導入模塊: from shogun.Classifier import LibSVM [as 別名]
# 或者: from shogun.Classifier.LibSVM import set_linear_term [as 別名]
for i in xrange(N):
try:
assert(abs(inner[i]-tmp_out[i])<= 0.001)
assert(abs(inner[i]-tmp_out2[i])<= 0.001)
except Exception, message:
print "difference in outputs: (%.4f, %.4f, %.4f)" % (tmp_out[i], tmp_out2[i])
###############
# compare to LibSVM
dasvm_manual_libsvm = LibSVM(1.0, wdk, lab)
dasvm_manual_libsvm.set_linear_term(linterm_manual)
dasvm_manual_libsvm.set_bias_enabled(False)
Math_init_random(1)
dasvm_manual_libsvm.train()
###############
# compare to LibLinear
dasvm_manual_liblinear = LibLinear(1.0, feat, lab)
dasvm_manual_liblinear.set_linear_term(linterm_manual)
dasvm_manual_liblinear.set_bias_enabled(False)
dasvm_manual_liblinear.train()