use fitcknn, fitcsvm

11 vues (au cours des 30 derniers jours)
Tu Nguyen
Tu Nguyen le 11 Mai 2022
Réponse apportée : arushi le 29 Août 2024
Hi all,
I have a template ECG signal, and I have 40 test of ECG. Now I have to use function fitcknn and fitcsvm to do machine learning classification for statistic.
But I dont know how to run the code, I put like this but the code returned error
I really appreciate for your help
M1 = fitcknn(template,ecg_test_rand);
M2 = fitcsvm(template,ecg_test_rand);

Réponses (1)

arushi
arushi le 29 Août 2024
Hi Tu Nguyen,
I understand that you are trying to classify ECG data using “fitcknn” and “fitcsvm” inbuilt function.
To classify ECG data using the built-in functions “fitcknn” and “fitcsvm”, you can refer to the provided code snippet:
% Load the data into the MATLAB workspace from the file
a = load("ecg.csv")
% Divide the data into Training data and Testing Data. You can try %different algorithms for data division
cv = cvpartition(size(a,1),'HoldOut',0.3);
idx = cv.test;
% Separate the training and test data
dataTrain = a(~idx,:);
dataTest = a(idx,:);
% Separate the input data and output data from the training data
dataTrainX = dataTrain(:,(1:end-1));
dataTrainY = dataTrain(:,end);
% Train the Model using the built-in functions
Mdl = fitcknn(dataTrainX, dataTrainY);
Md2 = fitcsvm(dataTrainX, dataTrainY);
For more information on “fitcknn” function, you can refer to the below Mathworks documentation link: -
For more information on “‘fitcsvm” function, you can refer to the below Mathworks documentation link: -
I hope this helps!

Catégories

En savoir plus sur AI for Signals dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by