为什么我从 svmpredict 得到一个空矩阵?
Why am I getting an empty matrix from 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。我的代码如下:
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
函数给出空输出,如下所示:
y2_predicted =
[]
accuracy =
[]
您没有得到输出预测的原因是您调用 svmpredict
不正确。有两种调用方式:
[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 个参数。因此,要解决您的问题,您可以这样做:
[y2_pred, accuracy, ~] = svmpredict(y2, x2, model)
如果您不关心决策值。如果你这样做,那么
[y2_pred, accuracy, decision_values] = svmpredict(y2, x2, model)
我想根据一个简单的时间序列进行预测。观察结果 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。我的代码如下:
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
函数给出空输出,如下所示:
y2_predicted =
[]
accuracy =
[]
您没有得到输出预测的原因是您调用 svmpredict
不正确。有两种调用方式:
[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 个参数。因此,要解决您的问题,您可以这样做:
[y2_pred, accuracy, ~] = svmpredict(y2, x2, model)
如果您不关心决策值。如果你这样做,那么
[y2_pred, accuracy, decision_values] = svmpredict(y2, x2, model)