libsvm
libsvm copied to clipboard
regression same values predicted
When I train my regression problem, I only get 1 and -1 for the weights of support vectors and it produces an exact same prediction for every test vectors.
Could you give more details? What's the screen output of the training process? On 2019-03-18 05:40, John Karasev wrote:
When I train my regression problem, I only get 1 and -1 for the weights of support vectors and it produces an exact same prediction for the test vectors.
-- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub [1], or mute the thread [2]. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/139", "url": "https://github.com/cjlin1/libsvm/issues/139", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
Links:
[1] https://github.com/cjlin1/libsvm/issues/139 [2] https://github.com/notifications/unsubscribe-auth/AFGwnij8M33tZJm7v3xaAjZJZhbS7Ppxks5vX4k4gaJpZM4b5rop
What I got is the same ! I always get the same prediction value, even if I've already changed the inputdata. Specifically, I used 9 precipitation factors and real precipitation data from 1951 to 2010 to train the SVM regression model. Then I input the factors from 2011 to 2016 to the model in order to get the predicted precipitation data. But all I got was an array with the same 6 numberslike[248 248 248 248 248 248]. When I change the inputdata, the result may change but still an array with the same six numbers. Sometimes the result array can be 'almost' the same, like [222.121971040339 217.475177855453 221.321911068434 215.667836808570 222.829461145174]. It's also been found that only if I input the data that is very very closed to the trainnig data(1951-2010 factors), the result can be quite well. Ironically, when I use some classic dataset (from my reference books), the result will be pretty pretty good. Add on, RBF kernel was used, too.
Could you provide more details? Sometimes you need to scale the target values before training SVR.
On 2022-04-28 00:13, Nuist-Lee wrote:
What I got is the same ! I always get the same prediction value, even if I've already changed the inputdata. Specifically, I used 9 precipitation factors and real precipitation data from 1951 to 2010 to train the SVM regression model. Then I input the factors from 2011 to 2016 to the model in order to get the predicted precipitation data. But ALL I GOT WAS AN ARRAY WITH THE SAME 6 NUMBERSlike[248 248 248 248 248 248]. When I change the inputdata, the result may change but still an array with the same six numbers. Sometimes the result array can be 'almost' the same, like [222.121971040339 217.475177855453 221.321911068434 215.667836808570 222.829461145174]. It's also been found that only if I input the data that is VERY VERY closed to the trainnig data(1951-2010 factors), the result can be quite well. Ironically, when I use some classic dataset (from my reference books), the result will be pretty pretty good. Add on, RBF kernel was used, too.
-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you commented.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/139#issuecomment-1111192872", "url": "https://github.com/cjlin1/libsvm/issues/139#issuecomment-1111192872", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
Links:
[1] https://github.com/cjlin1/libsvm/issues/139#issuecomment-1111192872 [2] https://github.com/notifications/unsubscribe-auth/ABI3BHWTXT32F7WA54ORUZTVHFRRZANCNFSM4G7GXIUQ
This is the code for trainning.
clear all
load ("predictionfactors.mat");
[tsx,TSXps]=mapminmax(InputdataS1');
[ts,TSps]=mapminmax(JHy');
TSX=tsx';
TS=ts';
%% 选择回归预测分析最佳的SVM参数c&g
[bestmse,bestc,bestg] = gaSVMcgForRegress(TS,TSX);
% 打印选择结果
disp('打印选择结果');
str = sprintf( 'Best Cross Validation MSE = %g Best c = %g Best g = %g',bestmse,bestc,bestg);
disp(str);
%% 利用回归预测分析最佳的参数进行SVM网络训练
cmd = ['-c ', num2str(bestc), ' -g ', num2str(bestg) , ' -s 3 -p 0.01 -t 2 '];
model = svmtrain(TS,TSX,cmd);
When I load ("predictionfactors.mat"), the workspace is as follows:
InputdataS1 is precipitation factors in the former 60 years, which is the trainning data.InputdataS2 is that in the latter 6 years, and is used for prediction.
JHy is precipitation data in the former 60 years, and JHt is the former one.
gaSVMcgForRegressis a function written by Faruto, which can find the best c and g in SVM by using Genetic Algorithm.
Then is the code for SVM regression prediction:
ttx=mapminmax('apply',InputdataS2',TSXps);
tty=mapminmax('apply',JHt',TSps);
TTX=ttx';
TTY=tty';
[predict_,mse] = svmpredict(TTY,TTX,model);
predict_ = mapminmax('reverse',predict_',TSps);
predict_ = predict_';
And then the value 'predict_' always be an array with same numbers, which means however I change my inputdata to the model, the prediction result is the same one.
In addition , @kevin031060 said he met the same issue when using Java interface ,and Python/Matlab is fine.While mine is using Matlab toolbox.
how does your TSX and TS look like? Could you show a few elements of them?
On 2022-04-28 13:26, Nuist-Lee wrote:
This is the code for trainning.
clear all load ("predictionfactors.mat");
[tsx,TSXps]=mapminmax(InputdataS1'); [ts,TSps]=mapminmax(JHy'); TSX=tsx'; TS=ts';
%% 选择回归预测分析最佳的SVM参数c&g
[bestmse,bestc,bestg] = gaSVMcgForRegress(TS,TSX);
% 打印选择结果 disp('打印选择结果'); str = sprintf( 'Best Cross Validation MSE = %g Best c = %g Best g = %g',bestmse,bestc,bestg); disp(str);
%% 利用回归预测分析最佳的参数进行SVM网络训练 cmd = ['-c ', num2str(bestc), ' -g ', num2str(bestg) , ' -s 3 -p 0.01 -t 2 ']; model = svmtrain(TS,TSX,cmd);
When I load ("predictionfactors.mat"), the workspace is as follows: [1] InputdataS1 is precipitation factors in the former 60 years, which is the trainning data.InputdataS2 is that in the latter 6 years, and is used for prediction. JHy is precipitation data in the former 60 years, and JHt is the former one. GASVMCGFORREGRESSis a function written by Faruto, which can find the best c and g in SVM by using Genetic Algorithm. Then is the code for SVM regression prediction:
ttx=mapminmax('apply',InputdataS2',TSXps); tty=mapminmax('apply',JHt',TSps); TTX=ttx'; TTY=tty'; [predict_,mse] = svmpredict(TTY,TTX,model); predict_ = mapminmax('reverse',predict_',TSps); predict_ = predict_';
And then the value 'predict_' always be an array with same numbers, which means however I change my inputdata to the model, the prediction result is the same one.
-- Reply to this email directly, view it on GitHub [2], or unsubscribe [3]. You are receiving this because you commented.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/139#issuecomment-1111760138", "url": "https://github.com/cjlin1/libsvm/issues/139#issuecomment-1111760138", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
Links:
[1] https://user-images.githubusercontent.com/78215393/165681156-c3ffb18d-82bd-4c3b-9981-0da5b3189034.png [2] https://github.com/cjlin1/libsvm/issues/139#issuecomment-1111760138 [3] https://github.com/notifications/unsubscribe-auth/ABI3BHROA6QBSFC5FZSJQU3VHIOQBANCNFSM4G7GXIUQ
TSX is prediction factors which are already transposed and normalizd and transposed again to be a 601 matrix.
TS is real precipitation data, operated as above. It's a 609 matrix.
I mean 60x1 and 60x9
问题解决了!谢谢林老师的耐心指导! Issue solved!!! Thanks for your patient help!!! The key is Y, which is the real precipitation data in my code named TS. In fact , I have 3 precipitation data for 3 different regions. And when I choose JH region, the issue occurs. I was always focused on the X, which is prediction factor in my code. While the Y is another part of trainning an SVR model, which was ignored for a long time. So the result is : One region cannot match well with those precipitation factors, while another region can.
OK. Glad to know your problems are solved
On 2022-04-29 01:18, Nuist-Lee wrote:
问题解决了!谢谢林老师的耐心指导! Issue solved!!! Thanks for your patient help!!! The key is Y, which is the real precipitation data in my code named TS. In fact , I have 3 precipitation data for 3 different regions. And when I choose JH region, the issue occurs. I was always focused on the X, which is prediction factor in my code. While the Y is another part of trainning an SVR model, which was ignored for a long time. So the result is : One region cannot match well with those precipitation factors, while another region can.
-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you commented.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/cjlin1/libsvm/issues/139#issuecomment-1112462065", "url": "https://github.com/cjlin1/libsvm/issues/139#issuecomment-1112462065", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
Links:
[1] https://github.com/cjlin1/libsvm/issues/139#issuecomment-1112462065 [2] https://github.com/notifications/unsubscribe-auth/ABI3BHQBNKWNO2ARFYCP2RLVHLB6TANCNFSM4G7GXIUQ