Effacer les filtres
Effacer les filtres

multiple feature for prediction time series data with libsvm

3 vues (au cours des 30 derniers jours)
agri kridanto
agri kridanto le 29 Juin 2015
Commenté : lemon Nation le 23 Sep 2019
I am using libSVM in Matlab for prediction time series data. Basically, i use 1 feature (15 min past) to predict the label (the next 15 min value) and i got a good result from there.
data = x(1:end-1); dataLabels = x(2:end);
But, when i used multiple feature (ex: 4 --> 15 min, 30 min,45 min,60 min past data) to predict next value, it gimme an error.
v1 = x(1:end-4);
v2 = x(2:end-3);
v3 = x(3:end-2);
v4 = x(4:end-1);
label = x(5:end);
data = [v1,v2,v3,v4];
dataLabels = label;
%splitting train test data
trainDataLength = round(length(data)*latih/100);
trainSet = data(1:trainDataLength);
trainLabels = dataLabels(1:trainDataLength);
testSet = data(trainDataLength+1:end);
testLabels = dataLabels(trainDataLength+1:end);
[MAPE,acc] = SVR(trainSet,trainLabels,testSet,testLabels,'nov-14');
Error says "Length of label vector does not match # of instances. model file should be a struct array". Then i am transpose the label.
SVR ran with 1 st iter but give no result with following message "label (1st argument) should be a vector (# of column is 1)." "Attempted to access predicted_label(:,1); index out of bounds because size(predicted_label)=[0,0]."
So, what should i do to solving this error ? Thanks in advance :)

Réponses (2)

Stalin Samuel
Stalin Samuel le 29 Juin 2015
  1 commentaire
agri kridanto
agri kridanto le 29 Juin 2015
Thanks for your answer sir, But, i thought that solution is for multiclass classification using libsvm. In that solution using 4 features in fisheriris dataset and class provided. i can run the solution without any problem, but in my case for regression which has time series data. I got the result with 1 feature (15min past data) and the label is next data. But i cant use 4 (60,45,30,15 min past data) feature as in my question.
Am i misunderstood your solution, sir ?

Connectez-vous pour commenter.


lemon Nation
lemon Nation le 23 Sep 2019
I am in the same difficulty as you,I think there may be something wrong with the setting of the tag
  1 commentaire
lemon Nation
lemon Nation le 23 Sep 2019
Just now this problem has been solved by me, sharing methods in the following hope can help you
Wrong codes:
clear all,clc
format compact;
nn = 5, n=10
x = -2.5:1.5
err=x.^2
model = svmtrain(err,x,'-s 3 -t 2 -c 2.2 -g 2.8 -p 0.01')
[py,accuracy,dv] = svmpredict(err,x,model)
%%
testx = nn+1:n
testy = zeros(10,1);% 理论y值无所谓
[ptesty,~,~] = svmpredict(testy,testx,model)
err = [py,ptesty]'
%% 出现如下问题:
>>label (1st argument) should be a vector (# of column is 1).
corrected codes
clear all,clc
format compact;
nn = 5, n=10
x = [-2.5:1.5]'
err=x.^2
model = svmtrain(err,x,'-s 3 -t 2 -c 2.2 -g 2.8 -p 0.01')
[py,accuracy,dv] = svmpredict(err,x,model)
%%
testx = nn+1:n
testy = zeros(10,1);% 理论y值无所谓
[ptesty,~,~] = svmpredict(testy,testx,model)
err = [py,ptesty]'
%% Tips
This is the first time answer others' questions and hope I hope I can keep the good habit of keeping records

Connectez-vous pour commenter.

Catégories

En savoir plus sur Statistics and Machine Learning Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by