multiple feature for prediction time series data with libsvm
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 :)
0 Kommentare
Antworten (2)
lemon Nation
am 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 Kommentar
lemon Nation
am 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
Siehe auch
Kategorien
Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!