Clear Filters
Clear Filters

Trained svm model can't make predictions with new data

2 views (last 30 days)
load('Model.mat');
new_data = [5.1, 3.5, 1.4, 0.2];
prediction = predict(Model, new_data);
matlab2017b,What can I do to make it right?thanks

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 29 Dec 2023
Presuming that you are working with fitrsvm() for regression model development, e.g.,
% E.g. Data for model training:
x_train = reshape(1:20, [10,2]);
y_train = (1:10)';
% Train regression SVM model:
SVM_model = fitrsvm(x_train, y_train);
% Predictor test data:
x_test = [20, 21; 24, 25];
% Make predictions using the trained model
y_pred = predict(SVM_model, x_test)
y_pred = 2×1
14.6763 18.3469
%% OR load the existing model (MODEL_SVM.mat contains the model called Model_SVM):
load('MODEL_SVM.mat')
y_pred2 = predict(Model_SVM, x_test)
y_pred2 = 2×1
14.6763 18.3469

Community Treasure Hunt

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

Start Hunting!