Why do I receive 'You must pass class labels as a vector.' error?
Show older comments
clear; clc;
X_train = readmatrix("x_train.csv",'NumHeaderLines',1);
X_test = readmatrix("x_test.csv",'NumHeaderLines',1);
y_train = readmatrix("y_train.csv",'NumHeaderLines',1);
y_test = readmatrix("y_test.csv",'NumHeaderLines',1);
model = fitcsvm(X_train, y_train, 'KernelFunction','rbf');
Here's my code. After trying to run I receive this error (error is in attached screenshot):
Answers (1)
Hiro Yoshino
on 15 Oct 2022
0 votes
It said the y_train is not a vector.
The argument should be any on of: categorical array, string array, character array, logical array, numerical array, cell array.
You should make sure you give right data for x and y respectively.
4 Comments
Daniil Podtesov
on 15 Oct 2022
Hiro Yoshino
on 15 Oct 2022
How could Y be two values? It should be one. (This must be a classification problem.)
You should extract either one and feed it into fitcsvm as appropriate.
Daniil Podtesov
on 15 Oct 2022
Hiro Yoshino
on 15 Oct 2022
Good luck 🤞
Categories
Find more on Call Python from MATLAB 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!