Extract some value from genetic algorithm tool addition to fitness function value

1 visualización (últimos 30 días)
Hi,
I use the genetic algorithm-ANN codes for classification. I share you part of my codes.
h= @(x)mse_test(x,net, P, Output);
ga_opt = gaoptimset('display','iter', 'TolFun', 1e-8, 'CrossoverFraction', cr, ...);
[x_ga_opt, final_err_ga, exfl, ouput] = ga(h,10*n+1,ga_opt);
I only can get the final_err_ga value. Bu also confusion matrix(conf) is calculated in ga tool but I cant see it in result screen end of the run. How can I extract the conf variable?
function cal = mse_test(x,net, P, Output)
....
cal=(1/Accuracy);
conf = confusionmat (Output, z);
end
I can share screenshot if necessary. Thank you very much.

Respuestas (2)

Alan Weiss
Alan Weiss el 21 de Nov. de 2018
I think that the easiest way would be to run everything in a nested function, as in this example.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 comentarios
Ebru PEKEL
Ebru PEKEL el 21 de Nov. de 2018
Thank you. But even in this example, matlab gave only the fval value. I want to fval value but not only. I want other values for that result.
I want to believe there is a solution for my problem.
Alan Weiss
Alan Weiss el 26 de Nov. de 2018
The nested function allows access to all variable values that you want. Simply pull the values into the main function from the nested functions. See Nested Functions.
Alan Weiss
MATLAB mathematical toolbox documentation

Iniciar sesión para comentar.


Ebru PEKEL
Ebru PEKEL el 4 de Dic. de 2018
Hi again,
I couldn't get through my problem. Cause I'm not competent at using Matlab I suppose. Could you help me if I upload my all codes in here? My problem is to exract last conf (variable) value from mse_test function.
I would be very grateful if you help. My files are included in the appendix.

Categorías

Más información sobre Genetic Algorithm en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by