Why am I getting an empty matrix from svmpredict?

。_饼干妹妹 提交于 2019-12-08 04:32:34

问题


I want to make predictions from a simple time series. The observations y=[11,22,33,44,55,66,77,88,99,110] and at time x=[1,2,3,4,5,6,7,8,9,10]. I am using epsilon-SVR from libsvm toolbox. My code is as follows:

x1 = (1:7)'; #' training set
y1 = [11, 22, 33, 44, 55, 66, 77]'; #' observations from time series
options = ' -s 3 -t 2 -c 100 -g 0.05 -p 0.0003 ';
model = svmtrain(y1, x1, options)
x2 = (8:10)'; #' test set
y2 = [88, 99, 110]'; #' hidden values that are not used for training
[y2_predicted, accuracy] = svmpredict(y2, x2, model)

But the svmpredict function is giving me null output as shown below:

y2_predicted =
     []
accuracy =
     []

回答1:


The reason you're not getting output predictions is that you are calling svmpredict incorrectly. There are two ways to call it:

[predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options')
[predicted_label] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options'

With the output of one argument and of 3, but not 2. So to fix your problem, you can do:

[y2_pred, accuracy, ~] = svmpredict(y2, x2, model)

if you don't care about the decision values. If you do, then

[y2_pred, accuracy, decision_values] = svmpredict(y2, x2, model)


来源:https://stackoverflow.com/questions/30305425/why-am-i-getting-an-empty-matrix-from-svmpredict

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!