简体   繁体   中英

Performing regression using LIBSVM in Matlab

I am working on multivariate time series estimation. I am not quite sure if LIBSVM does that. How can I solve the basic univariate linear problem?

Suppose I have x = [1990,1991,1992,1993,1994] and y = [1,2,3,4,5]. Now I would like to predict the value at testx = 1995 using LIBSVM in Matlab. I tried using the toolbox but the results I got is

model = svmtrain(y,x,'-s 3 -t 0 -c 1 -p 0.1');
*
optimization finished, #iter = 0
nu = 0.000000
obj = 0.000000, rho = -1.000000
nSV = 0, nBSV = 0
>> TST = 6;
[predicted_label, accuracy, prob_estimates]=svmpredict(TST,testx,model);
Mean squared error = 25 (regression)
Squared correlation coefficient = -1.#IND (regression) 

What is going on here? As the data I gave is linear I have chosen -t 0 which is linear kernel.

I finally figured out what's wrong. The input I am passing through is a row vector. Libsvm takes an input in a column vector format. x should be m*n where m is the number of data and n is the number of features and y is a column label vector. Thanks to Sriram who helped me solve the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM