フィルターのクリア

Trained svm model can't make predictions with new data

2 ビュー (過去 30 日間)
li li
li li 2023 年 12 月 29 日
回答済み: Sulaymon Eshkabilov 2023 年 12 月 29 日
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

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023 年 12 月 29 日
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

カテゴリ

Help Center および File ExchangeSupport Vector Machine Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by