Predict Test Sample Response for SVM Regression Model

1 次查看(过去 30 天)
Hi
I am running test on data samples using the example of SVM Regression Model, in the case of the example given in this MathWorks documentation (link) the training data needs to have the same number of rows as the predict data, this is required so far to be able to run the prediction. What can I do if my data varies from the number of rows? How can I train my support vector machine with a data that have diferent number of samples and still be able to predict with the consequence of having maybe bigger error?
Data sample of the training data for the model and the data that I want to use for Mdl = fitrsvm.
ans=10×2 table
Training data Data to predict
_____________ ______________
14 9.4833
27 28.938
10 7.765
28
22 21.054
29 31.484
24.5 30.306
18.5
32 28.225
28

回答(1 个)

Bhargavi Maganuru
Bhargavi Maganuru 2019-9-11
You can make changes in the example given in MathWorks documentation page to use different data which has different number of samples.
load carsmall
tbl = table(Horsepower,Weight,MPG);
N = size(tbl,1);
Instead of using carsmall dataset you can load your own dataset.
rng(10); % For reproducibility
cvp = cvpartition(N,'Holdout',0.1);
idxTrn = training(cvp); % Training set indices
idxTest = test(cvp); % Test set indices
You can partition your own data into training data and the testing data using cvpartition(N,’HoldOut’,p) by setting p to get p*N number of test samples.
Also ObservedValuevariable in the ans table is the actual target value for the test data and the PredictedValue variable in the ans table is the predicted value for the test data.
  1 个评论
antlhem
antlhem 2019-9-16
编辑:antlhem 2019-9-16
Thank you for your reply. So far I have managed to train my SVM model modifying data from carsmall. But my question remains because, the YFit = predict(Mdl,tbl(idxTest,:)); asks all the time to have the same number of samples as the train sample. My question is. How to use the trained model for samples that were not in the training table? I would like to use trending of the model as well to predict the data that were not initially in the training model, like the table below. How to achieve this?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Support Vector Machine Regression 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by