close all; clear; clc; % Lire la base de données load fisheriris X = meas; Y = species; rng(10) % Construire le modèle KNN % MonModele = fitcknn(X,Y,'NumNeighbors',4); rng(1) MonModele = fitcknn(X,Y,'OptimizeHyperparameters','auto',... 'HyperparameterOptimizationOptions',... struct('AcquisitionFunctionName','expected-improvement-plus')) %MonModele= fitcknn(X,Y,'NSMethod','exhaustive','Distance','euclidean'); MonModele.NumNeighbors = 3; % Examine the resubstitution loss, which, by default, % is the fraction of misclassifications from the predictions of Mdl. % (For nondefault cost, weights, or priors, see loss.). rloss = resubLoss(MonModele) % % Construct a cross-validated classifier from the model. % MonModele_CV = crossval(MonModele,'KFold',10); % kloss = kfoldLoss(MonModele_CV) % Predict or test flwr = mean(X*2); % an average flower flwrClass = predict(MonModele,flwr)