Predict Test Sample Response for SVM Regression Model
3 views (last 30 days)
Show older comments
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.
Training data Data to predict
Bhargavi Maganuru on 11 Sep 2019
You can make changes in the example given in MathWorks documentation page to use different data which has different number of samples.
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.
Find more on Support Vector Machine Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!