Is it possible to run the classification learner app in a loop?

I want my classification learner app to run with some generted data , but I keep having to do this again and again. Is there a way to run it with the generated data input using all classifiers and specifying the amount of cross-validation and finally export the results of all the classifier everytime I run.

Answers (1)

yes,sir,just as
method,we can see
clc; clear all; close all;
warning off all;
x = [1 1 1 1 2 2 2 2 3 3 3 3];
y = categorical(["dog" "dog" "dog" "dog" "cat" "cat" "cat" "cat" "bird" "bird" "bird" "bird"]);
funcs = {@fitcknn @fitcecoc @fitctree};
n_funcs_given = numel(funcs);
A = cell(1,n_funcs_given);
B = cell(1,n_funcs_given);
% loop for every model method
for i = 1:n_funcs_given
% model fit
A{i} = funcs{i}(x(:),y(:));
% cross val
crossval_i = crossval(A{i});
B{i} = kfoldLoss(crossval_i);
end
A
A = 1×3 cell array
{1×1 ClassificationKNN} {1×1 ClassificationECOC} {1×1 ClassificationTree}
B
B = 1×3 cell array
{[0]} {[0]} {[0.3333]}

Categories

Asked:

on 12 Feb 2019

Commented:

on 30 Dec 2021

Community Treasure Hunt

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

Start Hunting!