为什么我从svmpredict获取一个空矩阵? [英] Why am I getting an empty matrix from svmpredict?

查看:427
本文介绍了为什么我从svmpredict获取一个空矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据一个简单的时间序列进行预测.观测值y=[11,22,33,44,55,66,77,88,99,110]和时间x=[1,2,3,4,5,6,7,8,9,10].我正在使用来自libsvm工具箱的epsilon-SVR.我的代码如下:

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)

但是svmpredict函数给了我空输出,如下所示:

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

y2_predicted =
     []
accuracy =
     []

推荐答案

未获得输出预测的原因是您错误地调用了svmpredict.有两种调用方式:

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'

使用一个参数和3的输出,但不输出2.因此,要解决您的问题,您可以执行以下操作:

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)

这篇关于为什么我从svmpredict获取一个空矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆